-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] Nullable object reference produce invalid code in kotlin, php, java, typescript-fetch and probably more #10593
Comments
I think we can achieve something overriding
for some languages |
Apprently typescript does not like the 3.1 syntax either
|
It's still in draft and the unit tests aren't completed yet, but I hava a working solutions for this issue. I will try to complete a proper PR tomorrow |
Just hit this issue. Is it still an issue? Did all the commits above get released? Thanks. |
I try to keep the pull request up to date but noboty ever merge it even if it's approved. I see that it's now conflicted, I'll fix it soon. |
@etremblay our apologies. We're busy with too many PRs. I'll try to spend some time this week to next to go through it and let you know I've any feedback or question. |
Don't worry, I know you have a lot on your plate. I updated the pull request with master and re-generated the samplesé |
Description
To represent nullable object property, openapi recommend using a oneOf constuct. In version 3.0 in can be done with the nullable property, and in 3.1, with the
null
type.3.0
3.1
In kotlin, the generatated type name is incorrect :
OneOfLessThanPropertyTypeGreaterThan
In php, the code is ok but the annotations produce an invalid class name :
OneOfPropertyType|null
In java the type is also wrong
In typescipt-fetch it produces a different result with 3.0 or 3.1 syntax
openapi-generator version
master - 5.2.1
OpenAPI declaration file content or url
Generation Details
docker run --rm -v ${PWD}:/local --user "${USER_ID}:${GROUP_ID}" openapitools/openapi-generator-cli:latest generate -i /local/model.yaml -g kotlin -o /local/kotlin
docker run --rm -v ${PWD}:/local --user "${USER_ID}:${GROUP_ID}" openapitools/openapi-generator-cli:latest generate -i /local/model.yaml -g php -o /local/php
docker run --rm -v ${PWD}:/local --user "${USER_ID}:${GROUP_ID}" openapitools/openapi-generator-cli:latest generate -i /local/model.yaml -g java -o /local/java
docker run --rm -v ${PWD}:/local --user "${USER_ID}:${GROUP_ID}" openapitools/openapi-generator-cli:latest generate -i /local/model.yaml -g typescript-fetch -o /local/typescript
Related issues/PRs
#2090
Suggest a fix
I went deep into the source code to understand how nullable types are handled.
ModelUtils.isNullable
seems to have some logic to handle this but I'm unable to make an unit test pass in this code path.I'm willing to contribute but may need some guidance.
The text was updated successfully, but these errors were encountered: