Skip to content
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

OneOf is currently not handled by OpenAPI code generator #522

Open
AdrienMDevMobile opened this issue Oct 15, 2024 · 6 comments
Open

OneOf is currently not handled by OpenAPI code generator #522

AdrienMDevMobile opened this issue Oct 15, 2024 · 6 comments

Comments

@AdrienMDevMobile
Copy link

OneOf is correctly not handled by the generator. He should come for the 3rd version, but is currently on the roadmap : https://openapi-generator.tech/docs/roadmap/#short-term
This is blocking for the different fields using OneOf to describe the possibility of beeing a value or null/empty.

@raphodn
Copy link
Member

raphodn commented Oct 15, 2024

Which field/endpoint is concerned by this ?

I don't mind taking the time to improve the API specs, but I need more info :)

@AdrienMDevMobile
Copy link
Author

Thank you !

There are 4 field using oneOf : price_per, currency, location_osm_type and source

Those field are seen multiple times
price_per, currency, location_osm_type of of PriceCreate
price_per, currency of PatchedPriceUpdate
currency of PatchedProofUpdate
price_per, currency, location_osm_type of PriceFull
price_per and currency of PriceUpdate
source of ProductFull
location_osm_type and currency of Proof
location_osm_type and currency of ProofFull
currency of ProofUpdate
location_osm_type and currency of ProofUpload

This lead to 4 incorrect files : PatchedPriceUpdateCurrency.kt
PatchedPriceUpdatePricePer
PriceCreateLocationOsmType.kt
ProductFullSource.kt

Yes, PatchedPriceUpdateCurrency is used in the generated files in every places where currency is used (not just patchedproficeupdate)

@AdrienMDevMobile
Copy link
Author

According to this stackoverflow user, empty string should rather be optional :
https://stackoverflow.com/questions/73244706/spring-boot-openapi-swagger-enums-with-empty-strings-generates-empty-inste

Since null/empty is exactly why we are using oneOfs, this may be the solution.

@AdrienMDevMobile
Copy link
Author

Is the oneOf that we can find like this :
oneOf:
- $ref: '#/components/schemas/LocationOsmTypeEnum'
- $ref: '#/components/schemas/BlankEnum'
- $ref: '#/components/schemas/NullEnum'

done to preemptively be compatible with v3.1 ?

If not, what is the purpouse when we already have nullable:true on all those fields ?

@raphodn
Copy link
Member

raphodn commented Oct 31, 2024

There are 4 field using oneOf : price_per, currency, location_osm_type and source

In the Django code, these fields indeed have restricted "choices", but can also be null.
For instance Price.price_per is null if the price is for a barcode product (but it will be filled if the price is for a category_tag)

@raphodn
Copy link
Member

raphodn commented Nov 13, 2024

OpenAPITools/openapi-generator#19258 oneOf + null / fixed & available in v7.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants