swagger-api / swagger-node

Swagger module for node.js
http://swagger.io
Apache License 2.0
3.97k stars 584 forks source link

Unable to get mock mode controller working for endpoints with paramters in path #458

Open hoodwink73 opened 7 years ago

hoodwink73 commented 7 years ago

Hello friends

I am trying to set up a mock API to work on my client side app independent of efforts from my server side team. And I want these mocks to be more meaningful instead of simple mock data as provided by swagger out of the box.

I am using swagger project start -m to start serving the apis from the default http://localhost:10010/. And I am serving some mock jsons from /api/mocks/users.js which exports multiple methods.

I am using correct values inside my swagger-spec for x-swagger-router-controller and operationId.

And I have got one path /users return the mock values for both GET and POST

However whenever I am trying to connect /users/{user-id} with my mock controller, its returning 404.

I am starting to think dynamic paths like /users/{user-id} cannot be handled by mock mode. Am I right to think so or is there a way to mock such paths?

thinkTank15 commented 7 years ago

I ran into same issue, Not sure but this seems to be the issue, if you replace dash(-) with underscore( _ ) in the path, that seems to work. Trying to find a way around this.