简体   繁体   中英

Sails swagger api documentation

I am using sails in my node js application. And want to implement swagger api documentation. And I follow Swagger Sails JS document. I got the result from my api doc . And my expected result from api doc . I have write the route in router.js file like below

'post /login': {
    controller: 'user/UserController',
    action: 'login',
    skipAssets: 'true',
    //swagger path object
    "get": {
      "tags": [
        "Users"
      ],
      "description": "Get a login user data",
      "parameters": [{
        "email": "abc@gmail.com",
        "password": "12345678y",
        "deviceToken": "12345678y",
        "deviceType": 2
      }],
      "responses": {
        "200": {
          "statusCode": 0,
          "status": true,
          "message": "string",
          "result": {}
        }
      }
    }
  }

If I had write wrong in my routes. Then how to write the routes, so that I will get my expected result from api docs?

Thanks!

You can try using this .

And I suppose router file should be like this:

'post /login': {
    controller: 'user/UserController',
    action: 'login',
    skipAssets: 'true',
    swagger: {
        methods: ["get"],
        tags: ["Users"],
        description: "Get a login user data",
        parameters: [{
            email: "abc@gmail.com",
            password: "12345678y",
            deviceToken: "12345678y",
            deviceType: 2
        }],
        responses: {
            '200': {
                statusCode: 0,
                status: true,
                message: "string",
                result: {}
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM