-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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-experimental] Add oneOf support #5150
[go-experimental] Add oneOf support #5150
Conversation
FTR, I don't think that the Shippable failure is related to this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fantastic. I'm going to give it a few days or so to get feedback from anyone else on the core team or collaborator team if they'd like to review.
cc @OpenAPITools/openapi-generator-core-team
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
...i-generator/src/main/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalData.java
Show resolved
Hide resolved
I retargeted to |
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
@jimschubert thanks for the review! I'll try to address the points that you raised during today. I checked the conflict resolution and it LGTM. Additionally, I recently submitted #5175 which will need to be extended to account for changes in this PR. I'd prefer if it was left until after this is merged, because rebasing this PR is harder. I'll leave a message on that PR as well to not add unnecessary work with rebasing. |
So I fixed the review comments as best I could. I will work on adding tests until EOW. |
modules/openapi-generator/src/main/resources/go-experimental/model.mustache
Outdated
Show resolved
Hide resolved
@@ -377,8 +377,9 @@ private void registerMustacheLambdas() { | |||
for (Object _implmo : models) { | |||
Map<String, Object> implmo = (Map<String, Object>) _implmo; | |||
CodegenModel implcm = (CodegenModel) implmo.get("model"); | |||
if (additionalDataMap.containsKey(implcm.name)) { | |||
additionalDataMap.get(implcm.name).addToImplementor(this, implcm, imports, addOneOfInterfaceImports); | |||
String modelName = toModelName(implcm.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📛Thank you!
I added some basic tests for the |
@bkabrda it's not easy to get at |
@jimschubert that sounds great. I'm assuming it's ok to not have this part tested ATM? I'll be happy to add the tests once the refactored code is pushed. LMK when this is ok to be merged, I'll do a rebase then (since this change now spans several files that tend to change quite often, I don't want to spend too much time rebasing it). |
Yeah, it's ok to leave out that test. I'm fine with a rebase and merge now. tbh, you've added more tests than most people do! |
Thanks :) let me do the rebase and let's get this merged! |
…s the oneOf interface
…odel.mustache Co-Authored-By: Jiri Kuncar <[email protected]>
01968ef
to
347eaf7
Compare
Rebased. I retested everything locally, but let's wait for CI anyway to make sure I did everything right. |
* [go-experimental] Add oneOf support * Fix docs for the oneOf models * isOneOfInterface => x-is-one-of-interface * Add proper warnings when inline models are used in oneOf choices * Add a convenience method to oneOf implementing structs to cast them as the oneOf interface * Update modules/openapi-generator/src/main/resources/go-experimental/model.mustache Co-Authored-By: Jiri Kuncar <[email protected]> * Fix retrieving data from additionalDataMap * Add basic tests Co-authored-by: Jiri Kuncar <[email protected]>
This PR adds
oneOf
support in the same way it was added for Java clients recently in #5120. It contains a lot of refactoring to be able to use the same mechanisms as were used to implement this feature for Java. Also see #4785 for discussion on semantics ofoneOf
and thoughts on why it was implemented that way for Java.Note that this PR doesn't contain any tests right now. I do want to add tests, but would like to do that after the general direction of this PR and the related refactoring is approved.
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.@antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09) @bkabrda (2019/07)