-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
After upgrading from v7.6.0 to v7.7.0, we have noticed that the generated code is invalid.
- The generated model class has an import of a class
ApiClientwhich is not generated. - The generated model class has a function
toUrlQueryString(String)that uses a static functionvalueToStringfrom the classApiClientwhich is not generated.
The old code was
joiner.add(String.format("%sfoo%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFoo()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));The new code is
joiner.add(String.format("%sfoo%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getFoo()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));openapi-generator version
7.7.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Example API v1
description: A reference API
contact: {}
version: 2.0.0
paths:
/demo:
get:
responses:
'200':
description: Test
content:
'application/json':
schema:
type: object
properties:
foo:
type: stringGeneration Details
language: java
library: native
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.7.0</version>
<configuration>
<generatorName>java</generatorName>
<skipValidateSpec>false</skipValidateSpec>
<generateApis>false</generateApis>
<generateSupportingFiles>false</generateSupportingFiles>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<output>${project.build.directory}/generated-sources</output>
<configOptions>
<sourceFolder>openapi</sourceFolder>
<useJakartaEe>true</useJakartaEe>
<withXml>true</withXml>
<serializationLibrary>jackson</serializationLibrary>
<library>native</library>
<dateLibrary>java8</dateLibrary>
<disallowAdditionalPropertiesIfNotPresent>false</disallowAdditionalPropertiesIfNotPresent>
</configOptions>
</configuration>
<executions>
<execution>
<id>demo</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>src/main/openapi/demo.yaml</inputSpec>
<configOptions>
<modelPackage>de.demo</modelPackage>
</configOptions>
</configuration>
</execution>
</executions>Steps to reproduce
- save the file above as
src/main/openapi/demo.yaml - add the above plugin configuration to a maven pom
- run
mvn generate-sources - check
target/generated-sources/openapi/de/demo/DemoGet200Response.java
Related issues/PRs
seems to be a regression from #18743
https://github.com/OpenAPITools/openapi-generator/pull/18743/files#diff-2eefc7a98c8e6aff3fa4589d8f2c364e7214c35e98806786e8dae207c42352df
Workaround
Set supportUrlQuery to false when toUrlQueryString is not needed.
Reactions are currently unavailable