Socket
Socket
Sign inDemoInstall

@kakkuk/serverless-aws-apigateway-documentation

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kakkuk/serverless-aws-apigateway-documentation - npm Package Compare versions

Comparing version 1.1.13 to 1.2.0

2

package.json
{
"name": "@kakkuk/serverless-aws-apigateway-documentation",
"version": "1.1.13",
"version": "1.2.0",
"description": "Serverless 1.0 plugin to add documentation and models to the serverless generated API Gateway",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -312,3 +312,9 @@ [![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)

To download the deployed documentation you just need to use `serverless downloadDocumentation --outputFileName=filename.ext`.
For `yml` or `yaml` extensions application/yaml content will be downloaded from AWS. In any other case - application/json.
By default, the documentation will be downloaded in JSON format (content-type: application/json).
To download it in YAML format (content-type: application/yaml), simply use `yml` or `yaml` extension in the "outputFileName" argument: `serverless downloadDocumentation --outputFileName=filename.yml`
By default, the documentation will be downloaded in OpenAPI 2.0 (Swagger).
To download it in OpenAPI 3.0, use `oas30` or `openapi30` type in the "exportType" argument: `serverless downloadDocumentation --outputFileName=filename.ext --exportType oas30`
Optional argument --extensions ['integrations', 'apigateway', 'authorizers', 'postman']. Defaults to 'integrations'.

@@ -315,0 +321,0 @@

@@ -11,3 +11,3 @@ 'use strict';

restApiId: restApiId,
exportType: 'swagger',
exportType: exportType(this.options.exportType),
parameters: {

@@ -63,1 +63,10 @@ extensions: extensionType(this.options.extensions),

function exportType(exportTypeArg) {
let awsExportType = 'swagger';
if (exportTypeArg === 'oas30' || exportTypeArg === 'openapi30') {
awsExportType = 'oas30';
}
return awsExportType;
}

@@ -44,23 +44,50 @@ describe('ServerlessAWSDocumentation', function () {

};
objectUnderTest.serverless.providers.aws.request.mockReturnValue(Promise.resolve({
body: 'some body',
}));
await objectUnderTest.downloadDocumentation();
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'integrations',
},
accepts: 'application/json',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.txt', 'some body');
});
it.each([['yml'], ['yaml']])('should successfully download documentation, %s extension', async (outputFileExtension) => {
const outputFileName = `test.${outputFileExtension}`;
objectUnderTest.options = {
outputFileName: outputFileName,
};
objectUnderTest._getRestApiId = () => {
return Promise.resolve('testRestApiId')
};
objectUnderTest.serverless.providers.aws.request.mockReturnValue(Promise.resolve({
body: 'some body',
}));
await objectUnderTest.downloadDocumentation().then(() => {
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'integrations',
},
accepts: 'application/json',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.txt', 'some body');
await objectUnderTest.downloadDocumentation();
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'integrations',
},
accepts: 'application/yaml',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith(outputFileName, 'some body');
});
it('should successfully download documentation, yaml extension', async () => {
it('should successfully download documentation, json extension, using unknown export type', async () => {
objectUnderTest.options = {
outputFileName: 'test.yml',
outputFileName: 'test.json',
exportType: 'graphql'
};

@@ -70,18 +97,44 @@ objectUnderTest._getRestApiId = () => {

};
objectUnderTest.serverless.providers.aws.request.mockReturnValue(Promise.resolve({
body: 'some body',
}));
await objectUnderTest.downloadDocumentation();
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'integrations',
},
accepts: 'application/json',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.json', 'some body');
});
it.each([['oas30'], ['openapi30']])('should successfully download documentation, json extension, using %s export type', async (exportType) => {
objectUnderTest.options = {
outputFileName: 'test.json',
exportType: exportType
};
objectUnderTest._getRestApiId = () => {
return Promise.resolve('testRestApiId')
};
objectUnderTest.serverless.providers.aws.request.mockReturnValue(Promise.resolve({
body: 'some body',
}));
await objectUnderTest.downloadDocumentation().then(() => {
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'integrations',
},
accepts: 'application/yaml',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.yml', 'some body');
await objectUnderTest.downloadDocumentation();
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'oas30',
parameters: {
extensions: 'integrations',
},
accepts: 'application/json',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.json', 'some body');
});

@@ -97,18 +150,18 @@

};
objectUnderTest.serverless.providers.aws.request.mockReturnValue(Promise.resolve({
body: 'some body',
}));
await objectUnderTest.downloadDocumentation().then(() => {
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'apigateway',
},
accepts: 'application/yaml',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.yml', 'some body');
await objectUnderTest.downloadDocumentation();
expect(objectUnderTest.serverless.providers.aws.request).toHaveBeenCalledWith('APIGateway', 'getExport', {
stageName: 'testStage',
restApiId: 'testRestApiId',
exportType: 'swagger',
parameters: {
extensions: 'apigateway',
},
accepts: 'application/yaml',
});
expect(objectUnderTest.fs.writeFileSync).toHaveBeenCalledWith('test.yml', 'some body');
});

@@ -115,0 +168,0 @@

@@ -48,2 +48,6 @@ 'use strict';

},
exportType: {
required: false,
type: 'string'
},
extensions: {

@@ -50,0 +54,0 @@ required: false,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc