I need to define a service that is used multiple times with change in parameters.I ran into a problem whenever I define it because when I define it second time, it automatically overwrites the previous one. Following is how I defined it.This is first definition:
/sevice :
post:
summary: Service ABC
description: |
This service is used to get ABC.
parameters:
- name: XYZ
in: query
description: '8'
required: true
type: number
format: integer
- name: LMN
in: query
description: '2'
required: true
type: number
format: integer
tags:
- ABC
responses:
'200':
description: An array of products
schema:
type: array
items:
$ref: '#/definitions/ABC'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
This is the second definition:
/sevice :
post:
summary: Service ABC
description: |
This service is used to remove ABC.
parameters:
- in: body
name: jsonData
description: Object that needs to be sended to the store.
required: true
schema:
$ref: '#/definitions/PQR'
tags:
- ABC
responses:
'200':
description: An array of products
schema:
type: array
items:
$ref: '#/definitions/LMN'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
Is it possible to have same path appear more than once in one API spec?
The Swagger/OpenAPI spec currently doesn't allow specifying such operations. The combination of verb+path uniquely identify an operation, query parameters do not affect it.
Thanks for the quick reply @webron .Hoping to see this feature soon in Swagger. Thanks again!!!
Ok, swagger 2.0 does not support this, but will it be supported in next version? (for my personal opinoin it is a big mistake to do not support such funcitonality)
It's undecided yet.
I also agree that this feature should be part of swagger. I assume that this constraint is the result of the view that RESTful APIs should strictly follow a RESTful architecture and each path should map to one resource. This isn't the case all of the time and sometimes an API can be represented in a more concise way by deviating from the REST architecture a little.
If this constraint is lifted and a single path can have multiple definitions with different parameters then all current cases can still be supported and it will enable more APIs to use swagger. I'd be interested to hear the counter argument. The only thing I can think is that a stricter specification keeps people from writing sloppy, nonuniform APIs, but I'm not sure if that is the role swagger should play.
For completeness, my specific use case is a single path that takes different body parameter types based on a header value. My plan was to define multiple path definitions for each header value and body parameter type pair. I could move the header value that results in a different body type to the path, but I am implementing a spec that generically defines header values independent of the transport protocol chosen. Conceptually, it matches the spec by keeping these as headers instead of putting them in the path.
Even with this constraint, swagger is awesome. Thanks for the great work.
Is there a solution for this issue now?
I'd like to be able to distinguish 2 apis with same base path but,
A solution to this issue would be helpful to accomplish the same.
Is swagger cached docs. As i removed some class from openApi.configuration.resourceClasses init params of web.xml but still swagger reading it and din't used new class path value which is passed in param-value
I have a similar issue. I have two routes in which one's path is part of the second one.
Eg. 1. GET /static/path/{id}
2. GET /path/{id}
when i try to document it with swagger, i could not find the /static/path/{id} in the swagger UI after building. though, no error is thrown. Any idea how to resolve this.?
Is it possible to have multiple HttpDelete methods in Swagger controller?
I mean I would like to have other routes in methods ConfirmReservation and CancelReservation, which both of them requires reservation id. Different route, same paramteres, different action.
The Swagger/OpenAPI spec currently doesn't allow specifying such operations. The combination of verb+path uniquely identify an operation, query parameters do not affect it.
if there are any solution now??
@ben1226q nope. This has nothing to do with the editor, but with the spec. If you'd like to see a change, voice your opinion at https://github.com/OAI/OpenAPI-Specification/.
@ben1226q FYI: https://github.com/OAI/OpenAPI-Specification/issues/1635
An example of where something like this would be useful... the QuickBooks Online API I'm working with and trying to automate with Microsoft Power Automate.
Create a customer
POST /v3/company/<realmID>/customer
Content type:application/json
Production Base URL:https://quickbooks.api.intuit.com
Sandbox Base URL:https://sandbox-quickbooks.api.intuit.com
{
"FullyQualifiedName": "King Groceries",
"PrimaryEmailAddr": {
"Address": "[email protected]"
},
"DisplayName": "King's Groceries",
"Suffix": "Jr",
"Title": "Mr",
"MiddleName": "B",
"Notes": "Here are other details.",
"FamilyName": "King",
"PrimaryPhone": {
"FreeFormNumber": "(555) 555-5555"
},
"CompanyName": "King Groceries",
"BillAddr": {
"CountrySubDivisionCode": "CA",
"City": "Mountain View",
"PostalCode": "94042",
"Line1": "123 Main Street",
"Country": "USA"
},
"GivenName": "James"
}
md5-0247ae14d308127fdac80ea796946bf3
POST /v3/company/<realmID>/customer
Content type:application/json
Production Base URL:https://quickbooks.api.intuit.com
Sandbox Base URL:https://sandbox-quickbooks.api.intuit.com
md5-b572b15ded2c354723e96018af175ec4
{
"domain": "QBO",
"PrimaryEmailAddr": {
"Address": "[email protected]"
},
"DisplayName": "Bill's Windsurf Shop",
"PreferredDeliveryMethod": "Print",
"GivenName": "Bill",
"FullyQualifiedName": "Bill's Windsurf Shop",
"BillWithParent": false,
"Job": false,
"BalanceWithJobs": 85.0,
"PrimaryPhone": {
"FreeFormNumber": "(415) 444-6538"
},
"Active": true,
"MetaData": {
"CreateTime": "2014-09-11T16:49:28-07:00",
"LastUpdatedTime": "2015-07-23T11:07:55-07:00"
},
"BillAddr": {
"City": "Half Moon Bay",
"Line1": "12 Ocean Dr.",
"PostalCode": "94213",
"Lat": "37.4307072",
"Long": "-122.4295234",
"CountrySubDivisionCode": "CA",
"Id": "3"
},
"MiddleName": "Mac",
"Taxable": false,
"Balance": 85.0,
"SyncToken": "3",
"CompanyName": "Bill's Windsurf Shop",
"FamilyName": "Lucchini",
"PrintOnCheckName": "Bill's Wind Surf Shop",
"sparse": false,
"Id": "2"
}
Definitely makes it a real pain because these are two distinct actions, but use the same path and verb. Really, the only difference is the request body.
Most helpful comment
An example of where something like this would be useful... the QuickBooks Online API I'm working with and trying to automate with Microsoft Power Automate.
Create a customer
Definitely makes it a real pain because these are two distinct actions, but use the same path and verb. Really, the only difference is the request body.