The selected path is not the right one
Hi, We have a problem with a PACT trying to test a /v1/field/all path because it is resolved as /v1/field/{field id:guid}. Do you have a workaround or do you agree that it is a bug?
Both paths exist in the swagger.json file:
"/v1/field/{fieldId}": {
"get": {
"tags": [
"FieldQuery"
],
"summary": "Returns the specified field",
"operationId": "V1FieldByFieldIdGet",
"consumes": [],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "fieldId",
"in": "path",
"description": "The Id of the field",
"required": true,
"type": "string",
"format": "uuid"
},
And
"/v1/field/all": {
"get": {
"tags": [
"FieldQuery"
],
"summary": "Returns all fields",
"operationId": "V1FieldAllGet",
"consumes": [],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "transactionId",
"in": "header",
"description": "Transaction Id for the request",
"required": false,
"type": "string"
}
],
"responses"
Comments (6)
-
-
reporter Yes, it would be perfect. I have tried by hand to place the non-templated path before the templated one and it works. But I don't know how to do it from code (i.e. order paths).
-
@xlegalles awesome, I've put this bug fix into my teams backlog, we'll get to it as soon as we can.
Just to be clear what we will do is update swagger-mock-validator to check for non-templated path matches before looking for path matches. Once we ship this fix it won't matter what order the paths appear in the swagger file.
-
reporter Perfect.
-
- changed status to closed
fix: paths without parameters not matching before paths with parameters
Close
#69→ <<cset b0f0f4e489cf>>
-
Fix released in version 4.0.1
- Log in to comment
@xlegalles I agree it's a bug.
The Swagger 2 specification does not define what the behaviour should be when a templated path and non-templated path both match a url, however the openapi-3 specification states this:
So my proposal would be to update the tool to check for non-templated path matches before looking for templated path matches. Will this fix the bug for your use case?