Skip to content

2.1 Routers

leonardo Rico edited this page Dec 3, 2017 · 8 revisions

Swagger (Router)

Create a file with .yaml extension in the /src/api/swagger folder

src/api/swagger/hello.yaml

/api/hello:
  x-swagger-router-controller: hello 
  get:
    operationId: list
    x-hide: false
    tags:
      - Hello
    summary: Get list Hello's
    responses:
      200:
        description: Success
      404:
        description: Not found
      500:
        description: Error  

Swagger (Router + middleware)

Create a file with .yaml extension in the /src/api/swagger folder

src/api/swagger/hello.yaml

/api/hello:
  x-swagger-router-controller: hello 
  get:
    operationId: list
    security:
      - Bearer: []
    x-security-scopes:
      - admin
      - other
    tags:
      - Hello
    summary: Get list Hello's
    description: Returns all hello
    responses:
      200:
        description: Success
      404:
        description: Not found
      500:
        description: Error

Options

  • /api/hello: url example http://localhost:3000/api/hello
  • x-swagger-router-controller: controller name in src/api/controllers/hello.js
  • get: REST operations (get, post, put, delete, patch)
    • operationId name method from src/api/controllers/hello.js
    • x-hide: Show or hide router in swagger specification (/docs)
    • security: middleware
    • x-security-scopes: roles required
    • tags: tag for docs to swaggger
    • summary: summary for docs to swagger
    • description: description for docs to swagger
    • responses states of possible responses
Clone this wiki locally