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

A new property additionalModelTypeAnnotations that allows to add any custom annotations on the top of generated java class model #10978

Merged
merged 2 commits into from
Jul 3, 2021

Conversation

Ravisankar-Challa
Copy link
Contributor

@Ravisankar-Challa Ravisankar-Challa commented Apr 15, 2021

A new property additionalModelTypeAnnotations that allows to add any custom annotations on the top of generated java class model

java -jar swagger-codegen-cli.jar generate -i swagger.yaml -l spring --additional-properties additionalModelTypeAnnotations="@com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true);@com.fasterxml.jackson.annotation.JsonInclude(JsonInclude.Include.NON_NULL)",dateLibrary=java8,interfaceOnly=true,useTags=true,serializableModel=true -o ravi

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

@Ravisankar-Challa Ravisankar-Challa changed the title A new property additionalModelTypeAnnotations that allows to add any custom annotations on to the top of generated java class model A new property additionalModelTypeAnnotations that allows to add any custom annotations on the top of generated java class model Apr 15, 2021
@Ravisankar-Challa
Copy link
Contributor Author

Ravisankar-Challa commented Apr 15, 2021

@HugoMario Could you please look in to this pull request.

…custom annotations on the top of generated java class model
@Ravisankar-Challa
Copy link
Contributor Author

@HugoMario Could please look in to this pull request

@u784912
Copy link

u784912 commented May 14, 2021

@Ravisankar-Challa / @HugoMario

When this change will be merged?

@Ravisankar-Challa
Copy link
Contributor Author

@HugoMario Could you please look in to this pull request

@HugoMario
Copy link
Contributor

HugoMario commented May 20, 2021 via email

@HugoMario HugoMario self-assigned this May 20, 2021
@HugoMario
Copy link
Contributor

Hey @Ravisankar-Challa sorry again for my delay response.

I like the idea proposed on this PR, however there are a few things that i think it should be implemented in a different way.

  • The annotations must be available to be used with simple names instead full names.
  • The semicolon should be addressed on template side.

I'm proposing this in order to keep the same behavior in template-generators relationship.

Let me know what you think about it, also i can help with the changes i'm proposing, just add me to your PR and let me know.

@Ravisankar-Challa
Copy link
Contributor Author

Ravisankar-Challa commented May 23, 2021

@HugoMario The idea for additionalModelTypeAnnotations is taken from open api generator. In open api code generator they are using semicolon. additionalModelTypeAnnotations let's us add any annotation on the top of generated classes. ex:- I want to add @entity annotation which comes from the package "javax.persistence" on the top of the generated classes. Then we have to provide full package name like this java -jar swagger-codegen-cli.jar generate -i swagger.yaml -l spring --additional-properties additionalModelTypeAnnotations="@javax.persistence.Entity" -o output. You are already assigned to this pull request.

@Ravisankar-Challa
Copy link
Contributor Author

@HugoMario Please look in to this pull request

@HugoMario
Copy link
Contributor

@Ravisankar-Challa i'm on it

@HugoMario HugoMario merged commit ca9a002 into swagger-api:master Jul 3, 2021
@HugoMario
Copy link
Contributor

LGTM thanks @Ravisankar-Challa !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants