Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
webholik committed Sep 7, 2023
1 parent 06d5027 commit c984919
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/data/valid_openapi/path_params_with_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets/{petId}": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "Id of pet",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"headers": {
"responseHeader1": {
"description":"Description of responseHeader1",
"required": true,
"schema": {
"type": "integer"
}
},
"responseHeader2": {
"description":"Description of responseHeader2",
"schema": {
"type": "integer"
}
}
}
}
}
}
}
}
}
11 changes: 11 additions & 0 deletions test/unit/convertV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const expect = require('chai').expect,
examplesOutsideSchema = path.join(__dirname, VALID_OPENAPI_PATH + '/examples_outside_schema.json'),
exampleOutsideSchema = path.join(__dirname, VALID_OPENAPI_PATH + '/example_outside_schema.json'),
descriptionInBodyParams = path.join(__dirname, VALID_OPENAPI_PATH + '/description_in_body_params.json'),
descriptionInPathParams = path.join(__dirname, VALID_OPENAPI_PATH + '/path_params_with_description.json'),
zeroDefaultValueSpec = path.join(__dirname, VALID_OPENAPI_PATH + '/zero_in_default_value.json'),
requiredInParams = path.join(__dirname, VALID_OPENAPI_PATH, '/required_in_parameters.json'),
multipleRefs = path.join(__dirname, VALID_OPENAPI_PATH, '/multiple_refs.json'),
Expand Down Expand Up @@ -552,6 +553,16 @@ describe('The convert v2 Function', function() {
});
});

it('should add description in path params', function (done) {
var openapi = fs.readFileSync(descriptionInPathParams, 'utf-8');
Converter.convertV2({ type: 'string', data: openapi }, { schemaFaker: true }, (err, conversionResult) => {
let description = conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description;
expect(err).to.be.null;
expect(description).to.equal('(Required) Id of pet');
done();
});
});

it('Should create collection from folder having one root file for browser', function(done) {
let folderPath = path.join(__dirname, '../data/petstore separate yaml'),
files = [],
Expand Down

0 comments on commit c984919

Please sign in to comment.