Created by: Nukesor
This PR fixes #12510 (closed)
Previously, the generated code tried to create an any
object with all possible variants of the oneOf
construct, if no descriminator was specified. I couldn't find out how to use a descriminator though, as this doesn't seem to be documented in the openapi standard.
Anyhow, the old behavior didn't make a lot of sense and the compiler also failed to build this code.
As a fix, the newly generated code now only returns the result of the ToJSON
function for the given variant.
I researched how to check for identity during runtime in TS, and it seems that the only way to do this is via custom typeguards functions?
Hence, I created a typeguard function for each interface in the style of instanceOf{{classname}}
.
The PR is split into two commits:
- The actual changes.
- The update of the samples.
I'm not sure if I'm supposed to ping the whole TS team, but the checklist talks about "members", so here we go
Sorry if that wasn't correct.
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
./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.0.1) (patch release),6.1.x
(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.