Skip to content

Commit e12d879

Browse files
committed
Add cases for testing required/optional properties
1 parent 1f7e031 commit e12d879

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

test/data/valid_openapi/description-test.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,44 @@ paths:
99
get:
1010
parameters:
1111
- name: spacecraftId
12-
description: PATH_PARAM_DESCRIPTION
12+
description: "Required spacecraftId path param"
1313
in: path
1414
required: true
1515
schema:
1616
type: string
17+
- name: pathParamOptional
18+
description: "Path param optional description"
19+
in: path
20+
required: false
21+
schema:
22+
type: string
1723
- name: limit
1824
in: query
19-
description: QUERY_PARAM_DESCRIPTION
25+
description: "QUERY PARAM DESCRIPTION"
26+
required: true
27+
schema:
28+
type: integer
29+
format: int32
30+
- name: optionalQueryParam
31+
in: query
32+
description: "QUERY PARAM Optional"
2033
required: false
2134
schema:
2235
type: integer
2336
format: int32
2437
- name: page
2538
in: header
26-
description: "HEADER_DESCRIPTION_NOT_PRESENT"
39+
description: "HEADER PARAM DESCRIPTION"
40+
required: true
41+
schema:
42+
type: string
43+
- name: offset
44+
in: header
45+
description: "HEADER PARAM Optional"
2746
required: false
2847
schema:
2948
type: string
49+
3050
summary: Read a spacecraft
3151
responses:
3252
"201":

test/unit/convertV2.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,13 +1177,22 @@ describe('The convert v2 Function', function() {
11771177
Converter.convertV2({ type: 'string', data: openapi },
11781178
{}, (err, conversionResult) => {
11791179
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[0].description.content).to.equal(
1180-
'QUERY PARAM DESCRIPTION'
1180+
'(Required) QUERY PARAM DESCRIPTION'
1181+
);
1182+
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[1].description.content).to.equal(
1183+
'QUERY PARAM Optional'
11811184
);
11821185
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description).to.equal(
1183-
'PATH PARAM DESCRIPTION'
1186+
'(Required) Required spacecraftId path param'
1187+
);
1188+
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[1].description).to.equal(
1189+
'Path param optional description'
1190+
);
1191+
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[0].description.content).to.equal(
1192+
'(Required) HEADER PARAM DESCRIPTION'
11841193
);
1185-
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.header[0].description).to.equal(
1186-
'HEADER PARAM DESCRIPTION'
1194+
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[1].description.content).to.equal(
1195+
'HEADER PARAM Optional'
11871196
);
11881197
done();
11891198
});

0 commit comments

Comments
 (0)