juhaku / utoipa

Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Apache License 2.0
2.39k stars 185 forks source link

Support for older OpenAPI spec versions #1130

Open sgg-jhodgson opened 5 days ago

sgg-jhodgson commented 5 days ago

Is it possible to support 3.0.3 in utoipa 5.0?

Unfortunately the the cpp generators I'm using don't seem to have great support for 3.1.0, none of them support allOf and this appears to be the method for defining nullable types in 3.1.0.

Thanks for the awesome library!

juhaku commented 5 days ago

It could, it just that I just ripped off the parts needed for the support. Though that support would need separate set of types per OpenAPI version which is not optimal. Also the code generation side would need some conditional logic based on selected version. Yet the could not be supported simultaneously but only via a feature flag.

Reason it does not support. is that the maintenance overhead gets quite big. The biggest eye sore for the between the OpenAPI 3.0.3 and 3.1. is the absence / presence of nullable field.

sgg-jhodgson commented 5 days ago

yeah fair enough - this is more a fault of the generator than utoipa tbh, was just hoping there might be a workaround.

Feel free to close if there's no real demand for this, hopefully generators will catch up!

sgg-jhodgson commented 4 days ago

Actually @juhaku one more point on this.

oneOf is often better supported than allOf, and after a bit of reading, in nullable situations it seems like using oneOf might be more appropriate.

What was the motivation behind using allOf?