Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy path variable description to generated collection #761

Merged
merged 5 commits into from
Sep 11, 2023
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
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"object-hash": "3.0.0",
"graphlib": "2.1.8",
"path-browserify": "1.0.1",
"postman-collection": "4.1.5",
"postman-collection": "4.2.1",
"swagger2openapi": "7.0.8",
"traverse": "0.6.6",
"yaml": "1.10.2"
Expand Down
57 changes: 57 additions & 0 deletions test/data/valid_openapi/description-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
openapi: "3.0.0"
info:
version: "1.0.0"
title: "Sample API"
description: Buy or rent spacecrafts

paths:
/space/{spacecraftId}:
get:
parameters:
- name: spacecraftId
description: "Required spacecraftId path param"
in: path
required: true
schema:
type: string
- name: pathParamOptional
description: "Path param optional description"
in: path
required: false
schema:
type: string
- name: limit
in: query
description: "QUERY PARAM DESCRIPTION"
required: true
schema:
type: integer
format: int32
- name: optionalQueryParam
in: query
description: "QUERY PARAM Optional"
required: false
schema:
type: integer
format: int32
- name: page
in: header
description: "HEADER PARAM DESCRIPTION"
required: true
schema:
type: string
- name: offset
in: header
description: "HEADER PARAM Optional"
required: false
schema:
type: string

summary: Read a spacecraft
responses:
"201":
description: The spacecraft corresponding to the provided `spacecraftId`
content:
application/json:
schema:
type: string
28 changes: 28 additions & 0 deletions test/unit/convertV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
path.join(__dirname, VALID_OPENAPI_PATH, '/query_param_with_enum_resolve_as_example.json'),
formDataParamDescription = path.join(__dirname, VALID_OPENAPI_PATH, '/form_data_param_description.yaml'),
allHTTPMethodsSpec = path.join(__dirname, VALID_OPENAPI_PATH, '/all-http-methods.yaml'),
descriptionTestSpec = path.join(__dirname, VALID_OPENAPI_PATH, '/description-test.yaml'),
invalidNullInfo = path.join(__dirname, INVALID_OPENAPI_PATH, '/invalid-null-info.json'),
invalidNullInfoTitle = path.join(__dirname, INVALID_OPENAPI_PATH, '/invalid-info-null-title.json'),
invalidNullInfoVersion = path.join(__dirname, INVALID_OPENAPI_PATH, '/invalid-info-null-version.json'),
Expand Down Expand Up @@ -294,7 +295,7 @@
});

// Need to handle collaping of folders
it.skip('Should generate collection with collapsing unnecessary folders ' +

Check warning on line 298 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (14.x)

Unexpected skipped mocha test

Check warning on line 298 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (16.x)

Unexpected skipped mocha test

Check warning on line 298 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (18.x)

Unexpected skipped mocha test
multipleFoldersSpec, function(done) {
var openapi = fs.readFileSync(multipleFoldersSpec, 'utf8');
Converter.convertV2({ type: 'string', data: openapi }, {}, (err, conversionResult) => {
Expand All @@ -306,7 +307,7 @@
done();
});
});
it.skip('Should collapse child and parent folder when parent has only one child' +

Check warning on line 310 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (14.x)

Unexpected skipped mocha test

Check warning on line 310 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (16.x)

Unexpected skipped mocha test

Check warning on line 310 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (18.x)

Unexpected skipped mocha test
multipleFoldersSpec1, function(done) {
var openapi = fs.readFileSync(multipleFoldersSpec1, 'utf8');
Converter.convertV2({ type: 'string', data: openapi }, { schemaFaker: true }, (err, conversionResult) => {
Expand All @@ -320,7 +321,7 @@
done();
});
});
it.skip('Should generate collection without creating folders and having only one request' +

Check warning on line 324 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (14.x)

Unexpected skipped mocha test

Check warning on line 324 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (16.x)

Unexpected skipped mocha test

Check warning on line 324 in test/unit/convertV2.test.js

View workflow job for this annotation

GitHub Actions / Unit-Tests (18.x)

Unexpected skipped mocha test
multipleFoldersSpec2, function(done) {
var openapi = fs.readFileSync(multipleFoldersSpec2, 'utf8');
Converter.convertV2({ type: 'string', data: openapi }, { schemaFaker: true }, (err, conversionResult) => {
Expand Down Expand Up @@ -1170,6 +1171,33 @@
});
});

it('should generate a collection with description for Query Params, Path variables and Headers', function(done) {
var openapi = fs.readFileSync(descriptionTestSpec, 'utf8');

Converter.convertV2({ type: 'string', data: openapi },
{}, (err, conversionResult) => {
expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[0].description.content)
.to.equal('(Required) QUERY PARAM DESCRIPTION');
expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[1].description.content)
.to.equal('QUERY PARAM Optional');
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description).to.equal(
'(Required) Required spacecraftId path param'
);
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[1].description).to.equal(
'Path param optional description'
);
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[0].description.content).to.equal(
'(Required) HEADER PARAM DESCRIPTION'
);
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[1].description.content).to.equal(
'HEADER PARAM Optional'
);
done();
});
});

it('Should have disableBodyPruning option for protocolProfileBehavior set to true for all types of request' +
allHTTPMethodsSpec, function (done) {
var openapi = fs.readFileSync(allHTTPMethodsSpec, 'utf8');
Expand Down
Loading