aws-apigateway-importer
v0.8.0
Published
API Gateway Swagger Importer
Downloads
3
Maintainers
Readme
aws-apigateway-importer
Not quite port of aws-apigateway-importer for Node. It's still very limited in that it will only wholesale import/delete APIs, it also will only handle Swagger JSON files.
Usage
See the example folder included in the repo for the swagger.json file.
var ApiImporter = require('aws-apigateway-importer');
var importer = new ApiImporter('swagger.json');
importer.create(function (err, result) {
if (err) {
return console.error(err);
}
importer.deploy(function (err, result) {
if (err) {
return console.error(err);
}
console.log(result);
});
});
If at anytime the deployment is unsuccessful due to an error the partially created API will be deleted.
Methods
new constructor(doc[, options])
Reads the swagger json file and prepares the contents for API creation.
Arguments
- doc (String | Object): The path to the Swagger file of a JavaScript object that has the same format as a swagger file.
- [options] (Object): Configuration options for the AWS ApiGateway service.
- loglevel (String):
debug
,info
,error
. See Loglevel for more information. - delay (Number): The time in milliseconds to wait between adding integrations and responses to resources.
- apigateway (Object): Any option available on the API Gateway constructor.
- loglevel (String):
create(callback)
Creates the full API (methods, integrations, etc), but does not deploy it to a server. The API name is pulled from info.title
in the swagger.json file.
Arguments
- callback(err, result) (Function): Run after creation.
deploy(callback)
Deploys the API so that it is reachable via the internet. the create
method must be called before the deploy
method.
The Stage name for the api is pulled from the basePath
property of the swagger.json file and the leading /
is removed.
Arguments
- callback(err, result) (Function): Run after deployment.
updateApi(callback)
Deletes all methods and resources on an existing API and recreates it from the Swagger configuration.
** Even if methods have the same path and signature they will have new resource IDs. This is a destructive operation for everything but the parent API. **
Arguments
- callback(err, result) (Function): Run after creation.