user1539343
user1539343

Reputation: 1669

openapi documentation how to handle extension in the path

I have URLs like:

/return/{pid}.xml?d1='123'&d2='345'
/return/{pid}.json?d1='123'&d2='345'

the swagger specification calls for: path:/return/{pid} ....

but how can I map the extension ie

path:/return/{pid}.xml

or

path:/return/{pid}.json

It is a jersey+spring mvc application - so both the URLs are hitting the same controller and only based on the extension the rest framework is going to generate the xml / json output.

I can't ignore the extension from the path ie: path:/return/{pid}

because the user needs to know that he/she has to provide the file extension as part of the URL. Also I can't use two paths corresponding to xml / json because they are treated the same by the application. In addition it will duplicate things (I am not sure whether there is a fall-through like mechanism just like "case" statements in c++/java "switch" block)

Upvotes: 0

Views: 617

Answers (1)

Mohit_Kalra
Mohit_Kalra

Reputation: 283

In Swagger specs,You can define the file extensions in the path as below :

/return/{pId}.{fileExtension}

and define the fileExtension in parameters .

also the below is valid (not for your case) :

/return/pid.{fileExtension}

Upvotes: 1

Related Questions