Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

fix: add api id to stack outputs #11

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = function(AWS) {

_buildDocumentation: function _buildDocumentation(result) {
this.restApiId = result.Stacks[0].Outputs
.filter(output => output.OutputKey === 'ApiId')
.filter(output => output.OutputKey === 'AwsDocApiId')
.map(output => output.OutputValue)[0];

this.getGlobalDocumentationParts();
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ class ServerlessAWSDocumentation {
const func = this.serverless.service.getFunction(functionName);
func.events.forEach(this.updateCfTemplateFromHttp.bind(this));
});

// Add models
this.cfTemplate.Outputs.AwsDocApiId = {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
};
}

afterDeploy() {
Expand Down
61 changes: 59 additions & 2 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('ServerlessAWSDocumentation', function() {
ExistingResource: {
with: 'configuration',
},
}
},
Outputs: {},
}
},
getFunction: jasmine.createSpy('getFunction').and.callFake((functionName) => {
Expand Down Expand Up @@ -135,6 +136,14 @@ describe('ServerlessAWSDocumentation', function() {
with: 'configuration',
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});

Expand Down Expand Up @@ -162,6 +171,14 @@ describe('ServerlessAWSDocumentation', function() {
with: 'configuration',
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});

Expand Down Expand Up @@ -277,6 +294,14 @@ describe('ServerlessAWSDocumentation', function() {
}
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});

Expand Down Expand Up @@ -354,6 +379,14 @@ describe('ServerlessAWSDocumentation', function() {
}
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});

Expand Down Expand Up @@ -422,6 +455,14 @@ describe('ServerlessAWSDocumentation', function() {
}
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});

Expand Down Expand Up @@ -533,6 +574,14 @@ describe('ServerlessAWSDocumentation', function() {
},
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});

Expand Down Expand Up @@ -588,6 +637,14 @@ describe('ServerlessAWSDocumentation', function() {
Properties: {},
},
},
Outputs: {
AwsDocApiId: {
Description: 'API ID',
Value: {
Ref: 'ApiGatewayRestApi',
},
}
},
});
});
});
Expand Down Expand Up @@ -750,7 +807,7 @@ describe('ServerlessAWSDocumentation', function() {
OutputKey: 'ApiKey',
OutputValue: 'nothing',
}, {
OutputKey: 'ApiId',
OutputKey: 'AwsDocApiId',
OutputValue: 'superid',
}],
}],
Expand Down