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

Add support for controlling output of OpenAPI Generator version in generated files #17952

Merged
merged 27 commits into from
Mar 9, 2024

Conversation

l3ender
Copy link
Contributor

@l3ender l3ender commented Feb 24, 2024

Overview

This PR implements the feature request described in #17681. It adds a global property/flag (hideGeneratorVersion) which is used to control whether the OpenAPI Generator version is outputted into generated files.

The default value for the new property is true, meaning the generator version detail will not be added to generated files. This seemed like the least impacting way to do make the change.

Therefore, the PR:

  • Adds OpenAPI version to codegen types (if property is configured) which did not previously add this information to generated files.
  • Any codegen types which previously added OpenAPI version to generated files now only show that information if the property is configured.

Resolves #17681.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.1.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@l3ender l3ender changed the title Add OpenAPI Generator version in generated classes Control OpenAPI Generator version in generated files Feb 25, 2024
@l3ender l3ender changed the title Control OpenAPI Generator version in generated files Add support for controlling output of OpenAPI Generator version in generated files Feb 25, 2024
@wing328
Copy link
Member

wing328 commented Feb 26, 2024

@l3ender thanks for the PR. Please kindly put the work on hold for the time being as it's changing 1000+ files.

Can you please PM me to discuss this further vis Slack tomorrow (Tue) or Wed? https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

My timezone is +0800 (Hong Kong)

@l3ender
Copy link
Contributor Author

l3ender commented Mar 1, 2024

Recapping the offline discussion with @wing328, the version will not be added behind an option. If users want to control the output differently, they can customize/override the default templates.

@wing328 wing328 marked this pull request as ready for review March 9, 2024 07:51
@wing328 wing328 requested a review from jimschubert as a code owner March 9, 2024 07:51
@wing328 wing328 merged commit cf2435f into OpenAPITools:master Mar 9, 2024
47 checks passed
@wing328
Copy link
Member

wing328 commented Mar 9, 2024

thanks for the PR, which has been merged.

I'll file another PR to make some minor improvements.

have a nice weekend

@wing328
Copy link
Member

wing328 commented Mar 9, 2024

update: removed generator name option sample and config via f61b7c2

@wing328 wing328 added this to the 7.4.0 milestone Mar 9, 2024
@l3ender l3ender deleted the generated-with-version branch March 10, 2024 22:54
@l3ender
Copy link
Contributor Author

l3ender commented Mar 10, 2024

Thanks for all the help with this, @wing328!

If you find in the future the desire to revisit the approach of controlling generator version output with an option, please let me know! If it's not a big deal to have to regenerate all samples for each version upgrade, then no worries.

Thanks again!

@rearl
Copy link

rearl commented Mar 19, 2024

Pity you didn't add the property/flag (hideGeneratorVersion) in the end. We would like to have this option as we check in our CI/CD pipeline which files have changed and only build modules with changed files and dependants. If the content of the generated files have not changed with a new version of the this plugin, there is no need to build this module (and dependants). Putting the generator version into the generated files causes unnecessary build.
Any chance you add the property/flag in a next version?

@wing328
Copy link
Member

wing328 commented Mar 20, 2024

@rearl for your use case, I've filed #18170 so that you can set generatorVersion to Custom or something else to avoid changes during version upgrade.

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

Successfully merging this pull request may close these issues.

[REQ] Add OpenAPI Generator version in generated classes
3 participants