Skip to content

Commit 17211ac

Browse files
authored
Merge pull request #761 from postmanlabs/feature/CUE-3989
Copy path variable description to generated collection
2 parents 50e1eb0 + 281abdd commit 17211ac

File tree

4 files changed

+101
-16
lines changed

4 files changed

+101
-16
lines changed

package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"object-hash": "3.0.0",
129129
"graphlib": "2.1.8",
130130
"path-browserify": "1.0.1",
131-
"postman-collection": "4.1.5",
131+
"postman-collection": "4.2.1",
132132
"swagger2openapi": "7.0.8",
133133
"traverse": "0.6.6",
134134
"yaml": "1.10.2"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: "1.0.0"
4+
title: "Sample API"
5+
description: Buy or rent spacecrafts
6+
7+
paths:
8+
/space/{spacecraftId}:
9+
get:
10+
parameters:
11+
- name: spacecraftId
12+
description: "Required spacecraftId path param"
13+
in: path
14+
required: true
15+
schema:
16+
type: string
17+
- name: pathParamOptional
18+
description: "Path param optional description"
19+
in: path
20+
required: false
21+
schema:
22+
type: string
23+
- name: limit
24+
in: query
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"
33+
required: false
34+
schema:
35+
type: integer
36+
format: int32
37+
- name: page
38+
in: header
39+
description: "HEADER PARAM DESCRIPTION"
40+
required: true
41+
schema:
42+
type: string
43+
- name: offset
44+
in: header
45+
description: "HEADER PARAM Optional"
46+
required: false
47+
schema:
48+
type: string
49+
50+
summary: Read a spacecraft
51+
responses:
52+
"201":
53+
description: The spacecraft corresponding to the provided `spacecraftId`
54+
content:
55+
application/json:
56+
schema:
57+
type: string

test/unit/convertV2.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const expect = require('chai').expect,
5454
path.join(__dirname, VALID_OPENAPI_PATH, '/query_param_with_enum_resolve_as_example.json'),
5555
formDataParamDescription = path.join(__dirname, VALID_OPENAPI_PATH, '/form_data_param_description.yaml'),
5656
allHTTPMethodsSpec = path.join(__dirname, VALID_OPENAPI_PATH, '/all-http-methods.yaml'),
57+
descriptionTestSpec = path.join(__dirname, VALID_OPENAPI_PATH, '/description-test.yaml'),
5758
invalidNullInfo = path.join(__dirname, INVALID_OPENAPI_PATH, '/invalid-null-info.json'),
5859
invalidNullInfoTitle = path.join(__dirname, INVALID_OPENAPI_PATH, '/invalid-info-null-title.json'),
5960
invalidNullInfoVersion = path.join(__dirname, INVALID_OPENAPI_PATH, '/invalid-info-null-version.json'),
@@ -1170,6 +1171,33 @@ describe('The convert v2 Function', function() {
11701171
});
11711172
});
11721173

1174+
it('should generate a collection with description for Query Params, Path variables and Headers', function(done) {
1175+
var openapi = fs.readFileSync(descriptionTestSpec, 'utf8');
1176+
1177+
Converter.convertV2({ type: 'string', data: openapi },
1178+
{}, (err, conversionResult) => {
1179+
expect(
1180+
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[0].description.content)
1181+
.to.equal('(Required) QUERY PARAM DESCRIPTION');
1182+
expect(
1183+
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[1].description.content)
1184+
.to.equal('QUERY PARAM Optional');
1185+
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description).to.equal(
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'
1193+
);
1194+
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[1].description.content).to.equal(
1195+
'HEADER PARAM Optional'
1196+
);
1197+
done();
1198+
});
1199+
});
1200+
11731201
it('Should have disableBodyPruning option for protocolProfileBehavior set to true for all types of request' +
11741202
allHTTPMethodsSpec, function (done) {
11751203
var openapi = fs.readFileSync(allHTTPMethodsSpec, 'utf8');

0 commit comments

Comments
 (0)