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

Adds Collapse Spec Options to Maven Plugin #17714

Merged

Conversation

dchauhan-twilio
Copy link
Contributor

@dchauhan-twilio dchauhan-twilio commented Jan 26, 2024

  • Adds a collapsedSpec option to the maven plugin that produces a single-file representation of the spec in the output directory.
  • Adds a includeCollapsedSpecInArtifacts option to the maven plugin that adds the collapsed spec file to the maven artifacts.

How to manually verify

  1. Add the maven plugin to a project.
  2. Add the collapsedSpec and includeCollapsedSpecInArtifacts options to the plugin configuration.
  3. Run mvn deploy
  4. Verify that the target directory contains the merged spec. This file name will match the collapsedSpec value.
  5. Verify the deploy repository contains the spec where the classifier name matches that of the collapsedSpec value.

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.

@wing328
Copy link
Member

wing328 commented Jan 26, 2024

Adds a collapsedSpec option to the maven plugin that produces a single-file representation of the spec in the output directory.

i think it's doable now.

if you use the java client generator, you will get api/openapi.yaml file which is a single file representing the spec.

@dchauhan-twilio dchauhan-twilio force-pushed the collapsed-file-and-publish branch 2 times, most recently from d041351 to 873094c Compare January 26, 2024 20:56
@dchauhan-twilio
Copy link
Contributor Author

Adds a collapsedSpec option to the maven plugin that produces a single-file representation of the spec in the output directory.

i think it's doable now.

if you use the java client generator, you will get api/openapi.yaml file which is a single file representing the spec.

I see, but looking for this capability in the maven generator as we build against poms. In our workflow, the openapi spec is committed with the java service repository. The repository build process will then generate the service resource handlers and a java client. We now have cases where clients in other languages need to generate a client, and while we lack a swagger hub store, adding the spec to the artifact repository works as a good alternative.

@dchauhan-twilio dchauhan-twilio marked this pull request as ready for review January 26, 2024 21:32
@dchauhan-twilio
Copy link
Contributor Author

@bbdouglas, @sreeshas, @jfiala, @lukoyanov, @cbornet, @jeff9finger, @karismann, @Zomzog, @lwlee2608, or @martin-mfg do one you mind reviewing this PR?

@wing328
Copy link
Member

wing328 commented Jan 31, 2024

@dchauhan-twilio thanks for the explanation. we can give it a try.

can you please update the readme with the new option?

https://github.com/OpenAPITools/openapi-generator/blob/873094cd3477be3f753746c22a9bd9347ec1bc03/modules/openapi-generator-maven-plugin/README.md

@wing328
Copy link
Member

wing328 commented Jan 31, 2024

@dchauhan-twilio
Copy link
Contributor Author

dchauhan-twilio commented Jan 31, 2024

@dchauhan-twilio thanks for the explanation. we can give it a try.

can you please update the readme with the new option?

https://github.com/OpenAPITools/openapi-generator/blob/873094cd3477be3f753746c22a9bd9347ec1bc03/modules/openapi-generator-maven-plugin/README.md

Good idea, added in the last commit de1a753

CI tests failed: https://github.com/OpenAPITools/openapi-generator/actions/runs/7673305908/job/21045742400?pr=17714

can you please take a look?

After the latest commit, tests have passed. Looks like it was unrelated to this PR, but something central that failed.

@dchauhan-twilio
Copy link
Contributor Author

@bbdouglas, @sreeshas, @jfiala, @lukoyanov, @cbornet, @jeff9finger, @karismann, @Zomzog, @lwlee2608, or @martin-mfg, I see you are the maintainers for this section of the repo. Can you please review?

@wing328
Copy link
Member

wing328 commented Feb 7, 2024

tests still failed. can you please take another look?

* Adds a collapsedSpec option to the maven plugin that produces a single-file representation of the spec in the output directory.
* Adds a includeCollapsedSpecInArtifacts option to the maven plugin that adds the collapsed spec file to the maven artifacts.
* Adds the new options to the maven plugin README.md.
* Corrects the casing of one of the schema files that was causing the tests to fail.
@dchauhan-twilio
Copy link
Contributor Author

tests still failed. can you please take another look?

@wing328 Apologies for the delay, been a busy week struggled to replicate locally. Found the bug in the end (it was a casing issue :face_palm). I have validated the workflows pass in my fork (see dchauhan-twilio#2) so hopefully once the workflows are approved to run in this repo, it will pass here too.

@wing328
Copy link
Member

wing328 commented Feb 9, 2024

No need to sorry. We all appreciate your contributions. Just triggered the workflow and let's see how that goes.

@dchauhan-twilio
Copy link
Contributor Author

@wing328 looks like all the tests passed. Can this be merged?

@wing328
Copy link
Member

wing328 commented Feb 15, 2024

looks good. let's give it a try

thanks for the PR.

@wing328 wing328 merged commit cedf170 into OpenAPITools:master Feb 15, 2024
15 checks passed
@wing328 wing328 added this to the 7.4.0 milestone Feb 15, 2024
kota65535 pushed a commit to kota65535/openapi-generator that referenced this pull request Feb 23, 2024
* Adds Collapse Spec Optionss to Maven Plugin

* Adds a collapsedSpec option to the maven plugin that produces a single-file representation of the spec in the output directory.
* Adds a includeCollapsedSpecInArtifacts option to the maven plugin that adds the collapsed spec file to the maven artifacts.

* Address Feedback Round 1

* Adds the new options to the maven plugin README.md.

* Fixes Unit Tests

* Corrects the casing of one of the schema files that was causing the tests to fail.
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.

None yet

2 participants