Swagger fake API with swagger-node

980 Views Asked by At

README.md on https://github.com/swagger-api/swagger-node says 'Kick the tires. Your API is live while you edit (Did we mention no code?)' -> 'Quit faking' on the next step.

So I was under impression that Swagger will generate a fake API for me. However, if I use such swagger.yaml:

swagger: '2.0'
     info:
       title: test
       description: test
       version: "1.0.0"
     host: localhost:10010
     schemes:
       - https
     basePath: /api
     produces:
       - application/json
       - text/event-stream
     consumes:
       - application/json
     paths:
        /pages:
         get:
           summary: test
           description: test
           responses:
             200:
               description: pages
               schema:
                 type: array
                 items:
                   $ref: '#/definitions/Page'
             default:
               description: Unexpected error
               schema:
                 $ref: '#/definitions/Error'

(where definitions are also given in config)

I receive 404 in both curl http://localhost:10010/api/pages and swagger editor (swagger project edit). I know about x-swagger-router-controller thing but I expected it to work out of the box. Am I doing something wrong?

1

There are 1 best solutions below

0
On

I should've read the docs more carefully. Swagger gives us the mock mode (swagger project start -m)