How do I install swagger in a Sails.js 1.x no-frontend project?

Viewed 382

I recently started a new sail.js 1.2.3 project for building apis. I installed the project with the --no-frontend option specified.

I have the following npm packages installed:

    "sails-hook-orm": "^2.1.1",
    "sails-hook-sockets": "^2.0.0",
    "sails-hook-swagger-generator": "^2.8.2",
    "sails-postgresql": "^1.0.2",
    "sails-swagger": "^0.5.1",
    "sails-util-micro-apps": "^1.1.1",
    "swagger-ui-dist": "^3.23.11",

I created a swagger folder in my project, and when I run sails lift , the swagger.json file gets rebuilt (I think correctly).

However, I cannot get swagger-ui configured to use the swagger.json file, and I can't get the sails.js project to display the swagger-ui docs.

Here's what I already tried: Swagger Sails JS

Here's the results from running sails lift:

debug: hookPath: C:\Users\...\node_modules\sails-swagger\dist\api\hooks\swagger
debug: marlinspike (swagger): loading config from C:\Users\...\node_modules\sails-swagger\dist\config
debug: In route `/swagger/doc`:
debug: The `cors.origin` config has been deprecated.
debug: Please use `cors.allowOrigins` instead.
debug: (See http://sailsjs.com/config/security for more info.)

debug: In route `/swagger/doc`:
debug: The `cors.methods` config has been deprecated.
debug: Please use `cors.allowRequestMethods` instead.

debug: In route `/swagger/doc`:
debug: When specifying multiple allowable CORS origins, the allowOrigins setting
debug: should be an array of strings. We'll split it up for you this time...

debug: marlinspike (swagger): loading Services from C:\Users\...\node_modules\sails-swagger\dist\api\services...
 warn: marlinspike (swagger): no Services found. skipping
debug: marlinspike (swagger): loading Models...
debug: marlinspike (swagger): loading Controllers...
debug: marlinspike (swagger): loading Policies...
 warn: marlinspike (swagger): no Policies found. skipping
No tag for this identity 'status'
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity 'swagger'
No tag for this identity 'swagger'
No tag for this identity 'swagger'
No tag for this identity 'swagger'
No tag for this identity 'swagger'
No tag for this identity 'swagger'
 info: ·• Auto-migrating...  (drop)
Swagger generated successfully
 info:  ✓ Auto-migration complete.

 warn: Ignored attempt to bind route (/swagger/doc) to unknown action :: { cors:
   { allowOrigins: [ 'http://swagger.balderdash.io' ],
     allowRequestMethods: 'GET,OPTIONS,HEAD',
     allRoutes: true,
     allowCredentials: true,
     allowRequestHeaders: 'content-type',
     allowResponseHeaders: '',
     allowAnyOriginWithCredentialsUnsafe: false },
  controller: 'SwaggerController',
  action: 'doc' }
 info: 
 info:                .-..-.
 info: 
 info:    Sails              <|    .-..-.
 info:    v1.2.3              |\
 info:                       /|.\
 info:                      / || \
 info:                    ,'  |'  \
 info:                 .-'.-==|/_--'
 info:                 `--'-------'
 info:    __---___--___---___--___---___--___
 info:  ____---___--___---___--___---___--___-__
 info: 
 info: Server lifted in `C:\Users\...`
 info: To shut down Sails, press <CTRL> + C at any time.
 info: Read more at https://sailsjs.com/support.

I want to run sails lift, have the swagger.json file updated, then have a route/path I can use to see the expected swagger ui.

Thanks in advance!```

0 Answers
Related