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

[Go] Client Models using AllOf, OneOf, or AnyOf Correctly Include time and os imports #14057

Closed
wants to merge 12 commits into from

Conversation

icubbon
Copy link
Contributor

@icubbon icubbon commented Nov 17, 2022

Addresses #13959

Currently, if a Model is an allOf the time and os imports are not correctly added to the generated file. This was introduced recently with a fix to not include those imports when the model is a composedSchema #13833. The logic in that fix was just slightly off as an allOf should be treated the same as a standard model.

If a model is an AllOf or does not have any composed schemas at all, the sub-models are in-lined defined in the struct. In this case, the standard logic of including the time and os imports apply.

If a model is a OneOf or AnyOf, the sub-models are included as pointers to the defined model. In this case, do not include those items in the logic of including time and os imports.

Added an example to samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml that covers the missing case.

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/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.
  • 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.

@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @wing328

…rectly, so doing an `allOf` that referenced a model containing a `time.Time` object would not import `time`.

Swap around the logic to instead remove the models that are not embedded but instead referenced via `oneOf` and `anyOf`.
…lting code so any `time` or `os` imports need to be included.
README.md Outdated
@@ -1,1214 +1,322 @@
<h1 align="center">OpenAPI Generator</h1>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@icubbon thanks for the PR. Why deleted the project's README ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not intended. I will resolve conflicts and re-run generate to fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wing328 The ci/circleci: node1 tests are failing with the below message. Is this a flaky test framework setup issue?

Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

@viswajithiii
Copy link
Contributor

Hello! We are running into this issue as well. Will this PR be merged soon? 🙂 Let me know if I can help with anything.

@icubbon
Copy link
Contributor Author

icubbon commented Jan 13, 2023

Gonna try a new PR without the updated example to see if that will pass CI

@icubbon icubbon closed this Jan 13, 2023
@vitaly-zdanevich
Copy link

Why closed? I have a problem that time is not imported.

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