openapi-generator
openapi-generator copied to clipboard
[BUG][Csharp][GenericHost] Client serialization of oneOf repeats discriminator
Fixes #16597 @mandrean @shibayan @Blackclaws @lucamazzanti @iBicha
In case of a submodel with sub-submodel (e.g. Shape with submodel Triangle, which has submodel EquilateralTriangle), the removal of the properties must start from the root. If Triangle is cleaned first, then Shape doesn't know which properties to remove anymore.
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:
(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./mvnw clean package ./bin/generate-samples.sh ./bin/configs/*.yaml ./bin/utils/export_docs_generators.sh
./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 correct branch:
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks) - [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.
This is an obvious improvement, though what I would really like to see is for the discriminator string not be in any of the classes. Once you're in the class, the discriminator is known, so requiring a string in the constructor is redundant. See this Whale constructor. We known it's a whale, so the string doesn't really need to be there at all. It's okay if we want to merge this though since it appears to fix the problem.
@gerwinjansen can you please take a look at the test failure when you've time?
https://github.com/OpenAPITools/openapi-generator/actions/runs/7247593357/job/20330032075?pr=17397
@wing328: I fixed it, it is ready for the next run. Please approve.
Error: Failures:
Error: CSharpGenericHostDiscriminatorTest.oneOfWithReferencesAndDiscriminatorTest:43 » NullPointer
Error: Tests run: 2110, Failures: 1, Errors: 0, Skipped: 0
Error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0:test (default-test) on project openapi-generator: There are test failures.
Error:
Error: Please refer to /home/runner/work/openapi-generator/openapi-generator/modules/openapi-generator/target/surefire-reports for the individual test results.
Error: Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
Error: -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
can you please take a look at the build failure when you've time?
ref: https://github.com/OpenAPITools/openapi-generator/actions/runs/8052044583/job/22465390581?pr=17397
@wing328: I fixed it, it is ready for the next run. Please approve.
This change wont be needed once my remove discrim pr is merged.
Can you try my branch to see if it works for you? https://github.com/OpenAPITools/openapi-generator/pull/18445
@devhl-labs: yes, it works for me. This PR can be closed without merge if your PR gets approved.