zmts / supra-api-nodejs

❤️ Node.js REST API boilerplate
MIT License
335 stars 89 forks source link

How to access swagger-ui? #4

Closed galih25 closed 5 years ago

galih25 commented 5 years ago

Hello, i’m just trying to implement your structure but I cannot access the swagger-ui. Could you share how to access it?

First of all, I would like to say thanks to share this great structure.

zmts commented 5 years ago

Hi! There is no swagger implementation. It have something much better :) You can get endpoint schema by adding ?schema=true to any request URI

For example(auth/LoginAction.js) POST: {{host}}/auth/login?schema=true will return

{
    "query": {},
    "params": {},
    "body": {
        "password": "string; min 8 chars; (required)",
        "email": "string; email; max 50 chars; (required)",
        "fingerprint": "string; min 10; max 50 chars; (required)"
    }
}

Swagger have one big issue it require updating on each endpoint changes, supra takes all endpoint description directly from model layer :)

There is how it works: https://github.com/zmts/supra-api-nodejs/blob/master/controllers/BaseController.js#L141

Good luck!