Skip to content

Conversation

@metasection
Copy link

This Pull Request addresses issue #11.

Usage / Implementation

  • You can optionally add an ‘authorizations’ parameter to each route with a space separated list of route-authorizations (Example: "admin super-admin").


    server.get({url: '/test/method/:data',
       authorizations: 'account',
       swagger: {
         summary: 'Get',
         notes: '',
         nickname: 'getTest'
       },
       validation: {
         data: { isRequired: true, description: 'Data', swaggerType: 'string', scope: 'path' }
       }}, function(req, res, next) {
          res.send( { data : "get" });
       });
  • The authorizations are listed in the swagger resources.json.

    "resourcePath": "/swagger/test",
    "apis": [
        {
            "path": "/test/method/{data}",
            "description": "",
            "operations": [
                {
                    "notes": null,
                    "nickname": "getTest",
                    "produces": [
                        "application/json"
                    ],
                    "consumes": [
                        "application/json"
                    ],
                    "responseMessages": [
                        {
                            "code": 500,
                            "message": "Internal Server Error"
                        }
                    ],
                    "parameters": [
                        {
                            "type": "string",
                            "dataType": "string",
                            "name": "data",
                            "description": "Data",
                            "required": true,
                            "paramType": "path"
                        }
                    ],
                    "authorizations": {
                        "type": "account"
                    },
                    "summary": "Get",
                    "httpMethod": "GET",
                    "method": "GET"
                }
            ]
        }
    
  • when swagger loads it will optionally call a third party plugin to verify the api_key (if provided) and user authorizations.

  • configuring the third party plugin is done by passing the 'authorizationsPlugin' in the configuration options.

    restifySwagger.configure(server, {
        info: {
            contact: 'email@domain.tld',
            description: 'Description text',
            license: 'MIT',
            licenseUrl: 'http://opensource.org/licenses/MIT',
            termsOfServiceUrl: 'http://opensource.org/licenses/MIT',
            title: 'Node Restify Swagger Demo'
        },
        apiDescriptions: {
            'get':'GET-Api Resourcen'
        },
                authorizationsPlugin: swaggerAuthorizations
    });
    

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.73%) when pulling b6a8496 on metasection:master into b405bca on z0mt3c:master.

@metasection
Copy link
Author

Any word? Ready to pull?

@metasection
Copy link
Author

Happy holidays!!!! You like the changes? Ready to pull?

@z0mt3c
Copy link
Owner

z0mt3c commented Jan 7, 2015

Thanks! Looks better... could you please add some more information about your "swaggerAuthorizations interface"? And that should it be ;-)

@qrpike
Copy link

qrpike commented Aug 10, 2016

@z0mt3c Any updates on this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants