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 (By default is false)
    • security: Middleware
    • x-security-scopes: Roles required in Middleware
    • tags: Tag for docs to swaggger /docs
    • summary: Summary for docs to swagger
    • description: Description for docs to swagger
    • responses: States of possible responses
Note:

More info in Swagger Specification

Clone this wiki locally