-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Allow the definition of an API path with template (like RFC6570) #394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you referring specifically to https://tools.ietf.org/html/rfc6570#section-3.2.8? |
Yes, If I use an API path like "/pet{?x,y}", swagger-editor raise an error because it expects a parameter called "{?x,y}". I think this is an issue but I found nothing about this case in swagger 2.0 specification. |
How is that different than specifying two query parameters called |
As for path parameters, it's a complement to specifying two query parameters called x and y. In swagger-editor, if I define a path like "/pet/{x}/{y}, it expects two path parameters called "x" and "y". Otherwise, if I define a path like "/pet{?x,y}", it expects one path parameter called "?x,y" instead of expecting two query parameters called "x" and "y". |
These are not path parameters, these are query parameters (the RFC refers to them as query as well). and I fail to see the difference between that and declaring two query parameters. Can you clarify the difference? |
There are no differences, it's just a clarification for the path. I'm using this notation, maybe I'm wrong and swagger-editor returns 2 errors : {
"swagger" : "2.0",
"info" : {
"title" : "usr",
"version" : "0"
},
"host" : "127.0.0.1",
"basePath" : "/",
"paths": {
"/user/{id}": {
"get": {
"summary" : "Get user",
"parameters" : [ {
"name" : "id",
"in" : "path",
"description" : "User id to fetch",
"required" : true,
"type" : "string"
}],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/User"
}
}
}
}
},
"/user/{?firstName,lastName,birthDate}": {
"get": {
"summary" : "Get users",
"parameters" : [ {
"name" : "firstName",
"in" : "query",
"description" : "User first name criteria",
"required" : false,
"type" : "string"
}, {
"name" : "lastName",
"in" : "query",
"description" : "User last name criteria",
"required" : false,
"type" : "string"
}, {
"name" : "birthDate",
"in" : "query",
"description" : "User birth date criteria",
"required" : false,
"type" : "string",
"format" : "date-time"
}],
"responses": {
"200": {
"description": "OK",
"schema": {
"items": {
"$ref": "#/definitions/User"
},
"type": "array"
}
}
}
}
}
},
"definitions": {
"User" : {
"description" : "Step of the delivery workflow",
"properties" : {
"firstName" : {
"description" : "User first name",
"type" : "string"
},
"lastName" : {
"description" : "User last name",
"type" : "string"
},
"birthDate" : {
"description" : "User birth date",
"type" : "string",
"format" : "date-time"
}
},
"type" : "object"
}
}
} |
We don't support that notation and it's not really required. Just use the path |
ok |
I think this needs to be supported and in a way related to this swagger spec issue. In spring we are able to have different controller methods based on query parameters specified. One could argue that it can be implemented as one path with a union of all the query parameters, but for a richer experience (I'm thinking hypermedia), the path needs to support link templates. |
Are you sure you linked to the right place, @dilipkrish? |
Yeah its vaguely related :) and I'll tell u why; its the corollary to the problem of one path multiple response/representations. Going by the example in that issue, instead of headers what if I decided to do that as part of the url
Another more pertinent example to this issue is the use case is where
In both cases the path is the same, but the required parameters are a distinct set of required fields. So I'd like to represent them as unique paths. |
That's pretty much #164. |
Yes absolutely, but this is a more specific on how it should be implemented in a standards compatible fashion. |
I agree, but let's add that information there instead of diverting it to a separate issue. |
you can check you swagger code with the online editor. please follow below link |
What we've added is here: |
In RFC6570, it is possible to define an URI Template like that : http://www.example.com/foo{?query,number}
The expansion process for expressions beginning with the question-mark ("?") operator follows the same pattern as form-style interfaces on the World Wide Web.
The text was updated successfully, but these errors were encountered: