openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

Add support for skipping metadata file generation to plugins

Open nebulon42 opened this issue 2 years ago • 4 comments

A different approach to #13699 not via global properties as I have found them to have a problematic interaction with the setGenerateMetadata method on the DefaultGenerator (global properties are set in the generate method and you have to be careful to not overwrite anything that would have been set by that method).

Also adds support to the CLI in the form of a --skip-generate-metadata option. Adds tests for the Gradle plugin and the CLI.

Fixes #15731 Supersedes #13699 (unless going via global properties is the better architectural decision)

PR checklist

  • [x] Read the contribution guidelines.
  • [x] 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.
  • [x] Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    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*. For Windows users, please run the script in Git BASH.
  • [ ] In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date
    
    Commit all changed files.
  • [x] File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.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.

nebulon42 avatar Jun 06 '23 07:06 nebulon42

The failure ... modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt: (866, 27): Unresolved reference: setGenerateMetadata seems to be caused by the updated JAR file of the openapi-generator being not available to the build of the Gradle plugin.

I'm not too familiar with GitHub Workflows but in the build stage the install target is executed and so the updated JARs should end up in the .m2 directory. However, I have not seen log messages related to that. The cache task tells me that the cache was not updated because a cache hit occurred. Also the openapi-generator-cli JAR is uploaded somewhere but not the others.

Do also the other JAR files need to be uploaded? Does the cache not work correctly and needs to be changed?

nebulon42 avatar Jun 06 '23 08:06 nebulon42

thanks for the PR. have you considered using .openapi-generator-ignore file to skip certain files from being generated?

or simply remove those files post code generation?

wing328 avatar Jun 20 '23 14:06 wing328

.openapi-generator-ignore is one of the files that the skip metadata option should skip.

Removing afterwards is of course possible but adds more complexity for users. And there is already an option to not generate those files at all which is just not exposed at the plugins. Since the CLI has this option I thought also the Maven and Gradle plugins should have it as the current state is inconsistent.

nebulon42 avatar Jun 21 '23 11:06 nebulon42

It would be nice if this could be skipped and the PR being merged.

dol avatar Dec 01 '25 13:12 dol