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

Commit

Permalink
fix: add api id to stack outputs (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchock authored Dec 28, 2016
1 parent ea38024 commit 83f8d76
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
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

0 comments on commit 83f8d76

Please sign in to comment.