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

Open
krishnaktcs opened this issue May 28, 2024 · 3 comments
Open

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

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

2 participants