Forum Discussion

rmschroeder's avatar
rmschroeder
Occasional Visitor
2 years ago

Polymorphic properties discrimated by path

I would like to specify that the value of the input parameter in the Path is used as a discrimator in the requestBody and responses of a call.

For example, If I could POST to a path /echo/{inputTypeName} where inputTypeName is oneOf [ Cat, Dog ].

If it is Cat, then the requestBody MUST be $ref:'#/components/schema/Cat' and the response should be the same.
If it is Dog, then the requestBody MUST be $ref:'#/components/schema/Dog' and the response should be the same.

Assume that Cat a Dog do not have any shared properties.

Is there a way to create an OpenApi 3.x spec that allows for this? 

No RepliesBe the first to reply