openapi-generator
openapi-generator copied to clipboard
[BUG] [JAVA][Jackson] serializationLibrary=jackson not working
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
For the moment it appears as though plain java is configured to use gson and the serializationLibrary option doesn't seem to apply.
Here's my maven setup:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/spec.yaml
</inputSpec>
<generatorName>java</generatorName>
<generateApis>false</generateApis>
<generateSupportingFiles>false</generateSupportingFiles>
<skipOverwrite>false</skipOverwrite>
<configOptions>
<dateLibrary>java8</dateLibrary>
<useCoroutines>true</useCoroutines>
<collectionType>list</collectionType>
<enumPropertyNaming>UPPERCASE</enumPropertyNaming>
<serializableModel>true</serializableModel>
<serializationLibrary>jackson</serializationLibrary>
</configOptions>
<configHelp>false</configHelp>
</configuration>
</execution>
</executions>
</plugin>
I also have added the following jackson dependencies:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.2</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable-version}</version>
</dependency>
the resulting model object all had:
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
openapi-generator version
openapi-generator-maven-plugin -> 5.1.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Not sure why the YAML isn't showing up, but as a reference I used the YAML from this issue to make sure mine wasn't the cause:
https://github.com/OpenAPITools/openapi-generator/issues/5989
ok, an update if I set the generator as spring then it works just fine; so this seems to be a bug in the java generator:
<generatorName>spring</generatorName>
Reproduces on 5.3.0
Hello. Any update on the above without changing the generator to spring and using the java one?
Reproduced on 5.4.0.
Reproduced on 6.1.0
This can't work because there is no mustache code in the JSON.mustache to generate a Jackson serializer. If jackson option is documented in the documentation it should be enabled in the code.