Skip to content
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

Path Parameter is not being passed through Request URL and Curl Command. #9979

Closed
krishnaktcs opened this issue May 28, 2024 · 9 comments
Closed

Comments

@krishnaktcs
Copy link

krishnaktcs commented May 28, 2024

Hi Everyone,

I am facing issues in swagger UI, all APIs are working fine in my local but not working in Production (only few APIs are working).
Earlier APIs was working fine in my local and Production but suddenly It stopped working.

version: Local and Production same version I am using.

"swagger-jsdoc": "^6.2.5",
"swagger-ui-express": "^4.5.0", 
"node": "^14.17.6"

example :
GET [/ABC/{First Parameter / ID}/{Second Parameter}]

Response :-

Code Details
404
Error: Not Found
Response body
Unrecognized response type; displaying content as text.

Download
[ xyz - BackEnd Application Server ] - Unknown Comman

Request URL

https://abc.com/ABC/{First Parameter / ID}/{Second Parameter}

curl -X 'GET' \ 'https://abc.com/ABC/{First Parameter / ID}/{Second Parameter}' \ -H 'accept: /'

Anyone can help me on this?

@char0n
Copy link
Member

char0n commented Jun 6, 2024

It's most probably because of the fact that swagger-client now utilizes spec compliant Path Templating implementation. The spec is still ambiguous about various cases like the one that probably affects you. More info OAI/OpenAPI-Specification#3256 (comment)

@krishnaktcs
Copy link
Author

Hi @char0n,

Thanks for addressing this issue.

We were also suspecting the same. So, we tried to remove extra space from endpoints parameter names, it works for single path parameter, but it doesn't work for more than one Path-parameter.

In case of multi parameters - we could see the value only for the first param and the second param will have undefined.

example :
GET [/ABC/{FirstParameter/ID}/{SecondParameter}]

FirstParameter:- 'xyz',
SecondParameter;- 'jkl'

Request URL
https://abc.com/ABC/xyz/{SecondParameter}

Response :-
Code Details
404
Error: Not Found
Response body
Unrecognized response type; displaying content as text.
Download
[ xyz - BackEnd Application Server] - Unknown Command

we also tried
GET [/abc/{firstparameterid}/{secondparameter}]

Response: same as above

Please let us know if there is any other alternative way to resolve this issue. Your help would be greatly appreciated.

Thanks.

@char0n
Copy link
Member

char0n commented Jun 7, 2024

Hm then that's strange. If you have path parameters matching the template (have you changed the Parameter Object.name field?), it should just resolve. There is a test guarantying this to work: https://github.com/char0n/openapi-path-templating/blob/main/test/resolve.js#L18

@igor-tatarnikov-idt
Copy link

Hi @char0n @krishnaktcs

Facing a similar problem with path parameter and URL like /api/books/isbn={isbn} - the isbn required parameter populated on Swagger UI never gets submitted in URL or cURL in an ASP.NET Core app referencing SwaggerUI v6.6.2 NuGet (5.17.10, if i'm mapping versions correctly). It does replace the URL template value with actual value in SwaggerUI v6.5.0.

So, my question is do you recognize a URL like api/foo={bar} as a non-RFC-compliant? or is it rather a bug?

@W-Lawless
Copy link

W-Lawless commented Sep 5, 2024

@char0n @krishnaktcs I am also seeing this issue. Please consider prioritizing this fix as it is part of the core functionality of the product and as-is severely limits it's usability.

Using

    "node_modules/swagger-ui-express": {
      "version": "5.0.1",

Here is there relevant yaml commented in-line using swagger-js-doc , with some details changed for security.

 * /api/v2/parent/{paramOne}/child/{paramTwo}:
 *   post:
 *     security:
 *       - bearerAuth: []
 *     description: Updates the data.
 *     tags: []
 *     consumes: ["application/json"]
 *     parameters:
 *       - name: paramTwo
 *         in: path
 *         required: true
 *         description: The child ID
 *         schema:
 *           type: string
 *         example: 1
 *       - name: paramOne
 *         in: path
 *         required: true
 *         description: The parent ID
 *         schema:
 *           type: string
 *         example: 35

In my testing, only the first parameter listed is properly interpolated into the cURL statement, and this behavior is consistently observable when re-ordering the parameters.

The relevant cURL statement will be as follows:


curl -X 'POST' \
  'http://localhost:3000/api/v2/parent/{paramOne}/child/1' \

@falbert-ptc
Copy link

Hello @char0n @krishnaktcs

I have recently updated Swagger UI to 5.17.14 and I am seeing regressions for all path parameters that contain the "=" sign (similar to the issue reported by @igor-tatarnikov-idt ).

My Swagger Spec looks like this:
"/GetMetaInfo(EntityName='{EntityName}')" : { "get" : { "tags" : [ "Service Endpoints" ], "summary" : "", "description" : "", "operationId" : "Function_GetMetaInfo_With", "parameters" : [ { "name" : "EntityName", "in" : "path", "description" : "The fully qualified entity or complex type name", "required" : true, "schema" : { "type" : "string" } } ], "responses" : { "200" : { "description" : "Success", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/MyFQN.EntityMetaInfo" } } } } } } }

I cannot revert to Swagger UI 5.17.6 because of DOMPurity library vulnerability.

@char0n
Copy link
Member

char0n commented Dec 3, 2024

Can you please confirm you can still see the issues in latest SwaggerUI release?

@falbert-ptc
Copy link

This seems to be resolved

@char0n
Copy link
Member

char0n commented Dec 4, 2024

@falbert-ptc thanks for confirming. Closing this issue. Please reopen if this is not resolved.

@char0n char0n closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants