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

mock mode does not work due to doc error #342

Closed
holleB opened this issue Jan 14, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@holleB
Copy link

commented Jan 14, 2016

I've tried the mock-mode follwoing the docs. I try to access the web app like so

curl -i http://127.0.0.1:10010/weather
HTTP/1.1 404 Not Found
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 20
Date: Thu, 14 Jan 2016 13:07:37 GMT
Connection: keep-alive

Cannot GET /weather

I expected { "message": "Sample text" }

The swagger debug output looks like

weather-project/ swagger project start -m
  swagger project.api: {"swaggerFile":"redacted/weather-project/api/swagger/swagger.yaml","name":"weather-project","main":"app.js","host":"localhost","basePath":"/","localUrl":"http://localhost/","port":80} +0ms
Starting: redacted/weather-project/app.js...
  project started here: http://localhost/
  project will restart on changes.
  to restart at any time, enter `rs`
  swagger-tools:middleware Initializing middleware +0ms
  swagger-tools:middleware   Identified Swagger version: 2.0 +4ms
  swagger-tools:middleware   Validation: succeeded +42ms
  swagger-tools:middleware:router Initializing swagger-router middleware +14ms
  swagger-tools:middleware:router   Mock mode: enabled +1ms
  swagger-tools:middleware:router   Controllers: +0ms
  swagger-tools:middleware:validator Initializing swagger-validator middleware +1ms
  swagger-tools:middleware:validator   Response validation: enabled +0ms
  swagger-tools:middleware:security Initializing swagger-security middleware +4ms
  swagger-tools:middleware:security   Security handlers: 0 +0ms
  swagger-tools:middleware:metadata Initializing swagger-metadata middleware +75ms
  swagger-tools:middleware:metadata   Identified Swagger version: 2.0 +0ms
  swagger-tools:middleware:metadata   Found Path: /weather +3ms
  swagger-tools:middleware:metadata GET /weather +5s
  swagger-tools:middleware:metadata   Is a Swagger path: true +0ms
  swagger-tools:middleware:metadata   Is a Swagger operation: true +0ms
  swagger-tools:middleware:metadata   Processing Parameters +1ms

Is it currently broken or am I missing a setup step?

-- EDIT
Ok, so I'm missing x-swagger-router-controller: weather. For me, that's a documentation bug.

-- EDIT
Should be closed

@webron

This comment has been minimized.

@josephearl

This comment has been minimized.

Copy link

commented Sep 6, 2016

Why does mock mode require x-swagger-router-controller? This seems unintuitive - I haven't created any controller yet so why does it need a name?

IMO ideally mock mode would not mock routes with both x-swagger-router-controller and operationId - these are ones I've already coded, but should just mock the routes without these attributes.

This would allow me to incrementally design my API, with real code, without having to restart Swagger Node all the time based on whether I'm implementing an API or designing a new one.

@xxd3vin

This comment has been minimized.

Copy link

commented Oct 21, 2016

I think it is a document bug.

https://github.com/swagger-api/swagger-node/blob/master/docs/mock-mode.md#quick-example-mock-mode-in-action

x-swagger-router-controller: weather is not include in the sample yaml config.

@holleB holleB changed the title mock mode does not work mock mode does not work due to doc error Sep 13, 2017

@holleB holleB closed this Jun 29, 2018

harish-ramesh added a commit to harish-ramesh/swagger-node that referenced this issue Mar 11, 2019

fix mock mode example
The given example doesn't actually work, as discussed in swagger-api#342

harish-ramesh added a commit to harish-ramesh/swagger-node that referenced this issue Apr 3, 2019

fix mock mode example
The given example doesn't actually work, as discussed in swagger-api#342

harish-ramesh added a commit to harish-ramesh/swagger-node that referenced this issue Apr 8, 2019

fix mock mode example
The given example doesn't actually work, as discussed in swagger-api#342

harish-ramesh added a commit to harish-ramesh/swagger-node that referenced this issue Apr 8, 2019

fix mock mode example
The given example doesn't actually work, as discussed in swagger-api#342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.