Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

mock mode does not work due to doc error #342

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

mock mode does not work due to doc error #342

holleB opened this issue Jan 14, 2016 · 3 comments

Comments

@holleB
Copy link

holleB 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
Copy link
Contributor

webron commented Jan 14, 2016

@josephearl
Copy link

josephearl 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.

@xx7y7xx
Copy link

xx7y7xx 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 as completed Jun 29, 2018
harish-ramesh pushed a commit to harish-ramesh/swagger-node that referenced this issue Mar 11, 2019
The given example doesn't actually work, as discussed in swagger-api#342
harish-ramesh pushed a commit to harish-ramesh/swagger-node that referenced this issue Apr 3, 2019
The given example doesn't actually work, as discussed in swagger-api#342
harish-ramesh pushed a commit to harish-ramesh/swagger-node that referenced this issue Apr 8, 2019
The given example doesn't actually work, as discussed in swagger-api#342
harish-ramesh pushed a commit to harish-ramesh/swagger-node that referenced this issue Apr 8, 2019
The given example doesn't actually work, as discussed in swagger-api#342
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants