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

Commit b3edff8

Browse files
msimperitchock
authored andcommitted
Map also description to model (#88)
1 parent d611551 commit b3edff8

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/index.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ describe('ServerlessAWSDocumentation', function () {
141141
ContentType: 'application/json',
142142
Name: 'TestModel',
143143
Schema: 'some complex schema',
144+
Description: 'the test model schema',
144145
},
145146
},
146147
OtherModelModel: {
@@ -152,6 +153,7 @@ describe('ServerlessAWSDocumentation', function () {
152153
ContentType: 'application/json',
153154
Name: 'OtherModel',
154155
Schema: 'some even more complex schema',
156+
Description: 'the other test model schema',
155157
},
156158
},
157159
NoSchemaModelModel: {
@@ -163,6 +165,7 @@ describe('ServerlessAWSDocumentation', function () {
163165
ContentType: 'application/json',
164166
Name: 'NoSchemaModel',
165167
Schema: {},
168+
Description: 'the other test model schema',
166169
},
167170
},
168171
ExistingResource: {

src/models.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,22 @@ function replaceModelRefs(restApiId, cfModel) {
4242
module.exports = {
4343
createCfModel: function createCfModel(restApiId) {
4444
return function(model) {
45-
return replaceModelRefs(restApiId,
46-
{
47-
Type: 'AWS::ApiGateway::Model',
48-
Properties: {
49-
RestApiId: restApiId,
50-
ContentType: model.contentType,
51-
Name: model.name,
52-
Schema: model.schema || {},
53-
},
54-
}
55-
);
45+
46+
let cfModel = {
47+
Type: 'AWS::ApiGateway::Model',
48+
Properties: {
49+
RestApiId: restApiId,
50+
ContentType: model.contentType,
51+
Name: model.name,
52+
Schema: model.schema || {},
53+
},
54+
}
55+
56+
if (model.description) {
57+
cfModel.Properties.Description = model.description
58+
}
59+
60+
return replaceModelRefs(restApiId, cfModel)
5661
}
5762
},
5863

src/models.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('ServerlessAWSDocumentation', function() {
5858
let modelInput = {
5959
contentType: 'application/json',
6060
name: 'TestModel',
61+
description: 'Test description',
6162
schema: {
6263
type: 'object',
6364
properties: {
@@ -98,7 +99,8 @@ describe('ServerlessAWSDocumentation', function() {
9899
}
99100
}
100101
}
101-
}
102+
},
103+
Description: 'Test description',
102104
},
103105
DependsOn: [
104106
'OtherModelNameModel'

0 commit comments

Comments
 (0)