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

bugfix: openapi code generator to consider schema changes #16735

Merged

Conversation

DeepikaSridhar2112
Copy link
Contributor

@DeepikaSridhar2112 DeepikaSridhar2112 commented Oct 5, 2023

Issue description : OpenApi code generator fails to regenerate the classes when changes are made to schema specifications.

Analysis: Open Api code generator task, org.openapitools.generator.gradle.plugin.tasks.GenerateTask is present in openapi-generator-gradle-plugin-5.4.0.jar. It scans changes across parameters provided as inputs and determines if code has to be regenerated on invocation.If schema changes made directly in openapi.yml it detects the change and re-generates the code. However it isnt aware of the location of the schema files refered via reference($ref) tags. Hence the open api code generator doesn't detect changes made to schema files.

Resolution: Adding schema location as an parameter to GenerateTask.kt resolves the issue. The plugin when executed detects changes made to reference schema files

@wing328
Copy link
Member

wing328 commented Oct 10, 2023

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https:/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https:/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@DeepikaSridhar2112
Copy link
Contributor Author

DeepikaSridhar2112 commented Oct 12, 2023

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https:/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https:/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

Hi,
Thanks a lot for reviewing the PR. Updated the commits to get it linked to github account.Can you please check

@wing328
Copy link
Member

wing328 commented Dec 13, 2023

thanks for the PR. would it be possible to add a test to cover the issue?

tests can be found in modules/openapi-generator-gradle-plugin/src/test/kotlin/

@wing328 wing328 modified the milestones: 7.2.0, 7.3.0 Dec 22, 2023
@wing328 wing328 modified the milestones: 7.3.0, 7.4.0 Feb 8, 2024
@wing328 wing328 modified the milestones: 7.4.0, 7.5.0 Mar 11, 2024
@wing328 wing328 modified the milestones: 7.5.0, 7.6.0 Apr 17, 2024
@codefish1
Copy link
Contributor

codefish1 commented Jul 31, 2024

thanks for the PR. would it be possible to add a test to cover the issue?

tests can be found in modules/openapi-generator-gradle-plugin/src/test/kotlin/

@wing328 We have been running into problems where we've split a large OpenAPI specification into numerous files, with a file for each object. These are all in various sub folders and pulled in using $ref: "/.schemas/foo.yml for example. Without marking the schema folder as an input directory for the generate task, Gradle will use it's cache since it doesn't think any inputs have changed, despite you making changes to foo.yml.

How would you suggest we add a test for this? I assume you already have tests covering how you import schemas via reference, and this change is around the Gradle caching when a change has been made after your first build.

@codefish1
Copy link
Contributor

@wing328 what would you suggest we do for a test on this as requested?

…enapitools/generator/gradle/plugin/tasks/GenerateTask.kt

Co-authored-by: David Morris <[email protected]>
@wing328
Copy link
Member

wing328 commented Sep 27, 2024

all tests passed via #19701

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.

4 participants