Forum Discussion

pjroth's avatar
pjroth
Occasional Visitor
4 years ago

Return an optional response

I would like to define an openapi specification that returns what would be an Optional<MyType> in Java.  This of course would need to be language agnostic and generators for clients could map this to language specific types.  I see there is anyOf/oneOf which could be use to describe two types but that isn't quite what I'd like to do.  I'd like an easy to use type that can be mapped to a language specific Optional object (java, scala, rust all have support for an optional type for example, Javascript has optional chaining support)

 

Is there a way to achieve this using the existing specification rules and openapi generator?

 

Thanks!

Peter

No RepliesBe the first to reply