Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Not generating @Deprecated annotations #12804

Closed
sourav-jha opened this issue Jul 8, 2022 · 10 comments · Fixed by #18917
Closed

[BUG] Not generating @Deprecated annotations #12804

sourav-jha opened this issue Jul 8, 2022 · 10 comments · Fixed by #18917

Comments

@sourav-jha
Copy link

sourav-jha commented Jul 8, 2022

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:/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>
@wing328
Copy link
Member

wing328 commented Jul 9, 2022

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.

@sourav-jha
Copy link
Author

same issue in 6.0.1 also

@quincy
Copy link

quincy commented Dec 21, 2022

This is still not working in 6.2.1 using the gradle plugin. The @Deprecated annotation is not generated on fields with deprecated: true.

@dschulten
Copy link

Still not working in 6.4.0

@pkoli
Copy link

pkoli commented Apr 25, 2023

Do we have any update on this issue, the issue seems specific to the spring-boot library type.

@KnechtRootrecht
Copy link

This also occurs in the quarkus library.

@Philzen
Copy link
Contributor

Philzen commented Jun 4, 2024

@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?

@ch4mpy
Copy link

ch4mpy commented Jun 10, 2024

@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>

@Philzen
Copy link
Contributor

Philzen commented Jun 11, 2024

@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?

@wing328
Copy link
Member

wing328 commented Jun 11, 2024

Please feel free to submit a PR to fix it or I will take a look over the weekend

Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 13, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 14, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 14, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 14, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 14, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 15, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 15, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 15, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 15, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 16, 2024
Philzen added a commit to Philzen/openapi-generator that referenced this issue Jun 16, 2024
wing328 pushed a commit that referenced this issue Jun 16, 2024
…cated` annotation with `generateBuilders=true` (#18917)

* Implement regression test for #12804

* Fix duplicate rendering of @deprecated annotation on Builder methods

* Regenerate samples

* Sort entries so it's easier to parse if an entry already exists

* Add sample that uses generateBuilders=true to test build matrix

Serves as an additional regression check for #12804

* Add --no-transfer-progress to mvn build command to increase log legibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants