openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

Fix x-discriminator-value processing

Open jpfinne opened this issue 1 year ago • 1 comments

Fix #17343 allowing correct marshalling/unmarshalling of objects using an x-discrimininator-value

Test various combination of swagger/openapi, modelNameSuffix...

PR checklist

  • [x] Read the contribution guidelines.
  • [x] 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.
  • [x] 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.
  • [x] File the PR against the [7.3.0]
  • [x] If your PR is targeting a particular programming language, @mention the [technical committee]@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08) , so they are more likely to review the pull request.

jpfinne avatar Feb 03 '24 14:02 jpfinne

cc @OpenAPITools/generator-core-team

wing328 avatar Feb 15 '24 08:02 wing328

can you please update the samples too? https://github.com/OpenAPITools/openapi-generator/actions/runs/7940713183/job/21756786029?pr=17781

wing328 avatar Feb 20 '24 09:02 wing328

@wing328 Sorry I'm new to the whole process. I've managed to install a portable version of git bash on my Windows laptop. And I can regenerate the samples.

JacksonTest on master is wrong in the test for

returns("CatDto", AnimalDto::getClassName)

It should be "Cat".

All the previous attempts tried to skip the generation of @JsonTypeName. It does not work for all cases (parent class, middle class...)

I've used here a new approach: the actual value in @JsonTypeName is set in a postProcessor

One native test does fail. I don't know why.

jpfinne avatar Feb 21 '24 20:02 jpfinne

@wing328 thank you for your review.

The latest commit uses a lambda for useJsonTypeName.

I'm a bit scared by the amount of samples updated.

There was some differences in rust generation due to a change in DefaultCodeGen. I've rollbacked that change so that this PR has no impact on Rust.

btw I use a portable version of Gitbash on Windows. It generates cr/lf for FILES. Is there a way to configure the EOL?

jpfinne avatar Feb 28 '24 12:02 jpfinne

It would be great if @wing328 or someone from the Java technical committee could take over reviewing this PR; both to add another perspective and because I currently can't work on this.

martin-mfg avatar Mar 07 '24 12:03 martin-mfg

It would be great if @wing328 or someone from the Java technical committee could take over reviewing this PR; both to add another perspective and because I currently can't work on this.

@wing328 now what?

jpfinne avatar Mar 13 '24 17:03 jpfinne