1.0.0 • Published 5 years ago

ah-swaggerclient-plugin v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

ah-swaggerclient-plugin

Generate API clients from Swagger 2.0/Open API 3.0 specifications!

CircleCI

This plugin uses the swagger-client library to attach API clients to the ActionHero api object.

To install:

(assuming you have node and NPM installed)

npm install --save ah-swaggerclient-plugin

Configuring the plugin

See config/swaggerClient.js for an example. It's pretty easy to do, just provide a name for the API and a URL to the Swagger doc.

e.g.

exports.default = {
    swaggerClient: (api) => {
        return {
            apis: [
                {
                    name: 'petStore',
                    swaggerDocUrl: 'https://petstore.swagger.io/v2/swagger.json',
                }
            ]
        };
    }
};

You can then access your API like this:

const petApi = api.swaggerClients.petStore.apis.pet

See the documentation for swagger-client for details on how to call API methods.

To Test:

npm test