[BUG] Not generating @Deprecated annotations
Description
We have deprecated an API in our yaml file. We are generating the code using open api generator maven plugin. The generated code has "@deprecated" in java comments but no "@Deprecated" annotation on the method.
openapi-generator version:5.4.0
OpenAPI declaration file content or url
yaml content:
paths:
'/debug-endpoint/v1/person/{id}':
get:
deprecated: true
summary: get person info
description: Get
parameters:
- name: Id
in: path
required: true
......
Generation Details
plugin config
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
<configuration>
<generateSupportingFiles>true</generateSupportingFiles>
<generatorName>spring</generatorName>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModelDocumentation>true</generateModelDocumentation>
<!-- Duplicate classes being generated due to https://github.com/OpenAPITools/openapi-generator/issues/2701 -->
<typeMappings>a=b</typeMappings>
<configOptions>
<oas3>true</oas3>
<useTags>true</useTags>
<withSeparateModelsAndApi>true</withSeparateModelsAndApi>
<delegatePattern>true</delegatePattern>
<withInterfaces>true</withInterfaces>
<library>spring-boot</library>
<dateLibrary>java8</dateLibrary>
<useSpringfox>false</useSpringfox>
<useSpringController>true</useSpringController>
<modelPropertyNaming>camelCase</modelPropertyNaming>
</configOptions>
<!-- Option to prevent openapi generator to strip off common prefix from enum values -->
<additionalProperties>removeEnumValuePrefix=false</additionalProperties>
<!-- <skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>-->
</configuration>
openapi-generator version:5.4.0
can you please try the latest stable version v6.0.1? there's been a lot of enhancements, bug fixes in the spring boot generator.
same issue in 6.0.1 also
This is still not working in 6.2.1 using the gradle plugin. The @Deprecated annotation is not generated on fields with deprecated: true.
Still not working in 6.4.0
Do we have any update on this issue, the issue seems specific to the spring-boot library type.
This also occurs in the quarkus library.
@sourav-jha This seems to have been fixed via #16493 – can you check if this is solved for you and close the issue if it is?
@Philzen, I now have it twice when using the spring generator with generateBuilders set to true. Generated Java code does not compile.
Sample broken Java code:
@Deprecated
public CredentialRepresentation.Builder device(String device) {
this.instance.device(device);
return this;
}
@Deprecated
This can be reproduced using for instance the Keycloak OpenAPI spec and the following Maven plugin configuration:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.6.0</version>
<configuration>
<generatorName>spring</generatorName>
<skipValidateSpec>true</skipValidateSpec>
<inputSpec>${project.basedir}/keycloak-admin-api.openapi.json</inputSpec>
<apiPackage>org.keycloak.admin.api</apiPackage>
<modelPackage>org.keycloak.admin.model</modelPackage>
<nameMappings>authTime=depreacatedAuthTime</nameMappings>
<configOptions>
<documentationProvider>none</documentationProvider>
<annotationLibrary>none</annotationLibrary>
<ensureUniqueParams>true</ensureUniqueParams>
<generateBuilders>true</generateBuilders>
<interfaceOnly>true</interfaceOnly>
<library>spring-http-interface</library>
<openApiNullable>false</openApiNullable>
<serializableModel>true</serializableModel>
<useOptional>true</useOptional>
</configOptions>
</configuration>
</plugin>
@wing328 This seems to be a regression introduced via #16493 in v7.0.1
Do you want to take a quick look or should i take over?
Please feel free to submit a PR to fix it or I will take a look over the weekend