Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created January 18, 2020 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hendrixroa/f6f80dce7592e9a0c97b8713256cda86 to your computer and use it in GitHub Desktop.
Save hendrixroa/f6f80dce7592e9a0c97b8713256cda86 to your computer and use it in GitHub Desktop.
Script to put rest api in format swagger to AWS APIGATEWAY
import AWS = require('aws-sdk');
import fs = require('fs');
import minimist = require('minimist');
const args: any = minimist(process.argv);
const apigateway = new AWS.APIGateway({
region: process.env.AWS_DEFAULT_REGION || 'us-east-2',
});
export class PutRestApi {
public async updateRestApi() {
process.chdir('..');
const params: any = {
body: fs.readFileSync(`./src/apps/api/.swagger/${args.spec}`),
failOnWarnings: false,
mode: 'overwrite',
parameters: {
endpointConfigurationTypes: args.type,
},
restApiId: args.api,
};
return await apigateway.putRestApi(params).promise();
}
}
const restApi: PutRestApi = new PutRestApi();
restApi
.updateRestApi()
.then((data: any) => {
// tslint:disable-next-line: no-console
console.log('Update api rest: ', data);
})
.catch((err: any) => {
// tslint:disable-next-line: no-console
console.error('error updating api rest: ', err);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment