Skip to content

Conversation

@Orachigami
Copy link

@Orachigami Orachigami commented Sep 20, 2021

Fixes: #2906
Fixes: #5381
Fixes: #8647
Fixes: #8860
Fixes: #9601
Fixes: #9981

Added tests oneOfModelsGeneration for Java Spring and Java Client which iterate through several specs with OneOf usage cases and check that OneOf models are generated and subtypes implement generated models. Java Client test also creates a cartesian product of specs and client libraries for regress tests.

How inline OneOf models generation is fixed

Added x-deduction and x-deduction-model-names for vendorExtensions. These extensions are used to generated Jackson annotation when the discriminator cannot be used. The discriminator uses the specific field value for deserialization decisions. However, according to the https://swagger.io/specification#discriminator-object first example, oneOf can be used without the discriminator object. This case can be handled with Jackson recently added JsonTypeInfo.Id.DEDUCTION option. DEDUCTION option forces Jackson to make deserialization decisions according to the available fields in the payload and Models which implement oneOf interface/class.

ToDo

  • Polymorphic primitives deserialization

Example output screenshots

Output examples
Specification usage OneOf code Model code

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 (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @nmuesch (2021/01)

Alexander and others added 28 commits August 30, 2021 12:01
* Fix ci again

* Improve .gitignore
)

* [kotlin][client] add support for okhttp requests with empty body

* [kotlin][client] add support for okhttp requests with empty body
* [swift5][client] Fix issue 9953

* [swift5][client] update docs
* Updated template so that generated code now renders docstrings and function parameters nicely in IDE.

Endpoints are still accessible in generated code, mainly to satisfy some test cases.

* fixed manual tests
- update stack/deps to LTS 18.10 for ghc-8.10.7
- fixes for GHC 9
- update samples
* Upgrade typescript-axios from 0.21.1 to 0.21.4

* Update samples
* Fix default value for kotlin class

* fix style: remove trailing line

* fix ktorm schema
…ded jackson DEDUCTION for cases without discriminator
* fix(rust,client): use local_var prefix for configuration

This avoids conflicting with params named "configuration".

* chore(rust,client): capture updated samples
…querystring which should not be encoded (e.g. "+" or ":") (fixes #3459) (#10424)
PiDelport and others added 11 commits September 21, 2021 11:36
… free form query parameters (#10428)

* [Java][RestTemplate][WebClient] fix issue #8352 handling of free-form
query parameters with Java

* replace tab by spaces

* commit samples files generated by the generate-samples.sh script
…r minor updates/fixes (#10434)

* add handling of array of oneOfs

* handle res model-type lowercase name +shorten code

* remove unnecessary vendor-extension model enum

* handle openapi lowercase schema name for array res

* change xs:anytype to string for file responses

* update checkstyles

* remove not needed imports again

* update samples

* upper/lowercase use local getdefault

* update  samples again
* fix: expose allowed values of the enum

Fixes #10385

* chore: update examples
* fix!: accept should not force application JSON 

Generated code offen provides range of accept methods.
This method improperly takes JSON as preferred

Example:
	localVarHTTPHeaderAccepts := []string{"application/zip", "application/json"}

* chore: generated changes
)

* [scala] fix byteArray mapping in AbstractScala

* fix testng framework instead of junit for sttp codegen

* regenerate scala examples

* regenerate docs and examples

* fix test
@wing328
Copy link
Member

wing328 commented Sep 22, 2021

@Orachigami thanks for the PR but looks like this PR contains commits not authored by you.

To resolve this, I wonder if you can file a new PR by cherry-picking the commits that belongs to you instead?

Let me know if you need help.

@rgranadosd
Copy link

Already tested but It isn't working for my example, it doesn't generate the correct classes, in fact, it generates what is currently generating which is classes that don't implement an interface

@Orachigami
Copy link
Author

Orachigami commented Sep 22, 2021

@rgranadosd could you please share with me an example with the incorrect output?
My current test showed these results:
image
image
image

@Orachigami
Copy link
Author

@wing328, it seems that I didn't understand you correctly. My original PR was #10286 against master. In this thread , you asked me to:

Can you please submit a PR against this branch with the suggested fix?

So I recreated PR against jburgess-spring_fix_5381_jb. As a result, diff against master shows commits from the original jburgess-spring_fix_5381_jb branch too.

I will rebase my branch to look like before merge with jburgess-spring_fix_5381_jb.

@Orachigami
Copy link
Author

Moved to #10463 as @Wing suggested

@Orachigami Orachigami closed this Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.