Merge branch 'split/develop/multiFileSupport' into feature/swagger20BundleSupport

This commit is contained in:
Erik Mendoza
2022-07-11 14:25:25 -05:00
9 changed files with 14 additions and 10 deletions

View File

@@ -672,7 +672,10 @@ module.exports = {
if (origin === BROWSER) {
path = pathBrowserify;
}
const initialComponents = generateComponentsWrapper(specRoot.parsed.oasObject, version),
const initialComponents = generateComponentsWrapper(
specRoot.parsed.oasObject,
version
),
initialMainKeys = getMainKeysFromComponents(initialComponents, version);
let algorithm = new DFS(),
components = {},

View File

@@ -281,7 +281,7 @@ function validateSupportedVersion(version) {
if (!version) {
return false;
}
let isValid = [DEFAULT_SPEC_VERSION, SWAGGER_VERSION, VERSION_3_1].find((supportedVersion) => {
let isValid = [DEFAULT_SPEC_VERSION, VERSION_3_1, SWAGGER_VERSION].find((supportedVersion) => {
return compareVersion(version, supportedVersion);
});
return isValid !== undefined;

View File

@@ -52,7 +52,7 @@ function generateObjectName(filePathName, hash = '') {
* @param {string} mainKey - The generated mainKey for the components
* @param {string} version - The current spec version
* @param {string} commonPathFromData - The common path in the file's paths
* @param {string} parentNodeKey - The key from the parent element of the trace
* @param {string} parentNodeKey - The parent key before the trace
* @returns {Array} - the calculated keys in an array representing each nesting property name
*/
function getKeyInComponents(traceFromParent, mainKey, version, commonPathFromData, parentNodeKey = undefined) {

View File

@@ -22,4 +22,4 @@
fromB:
type: string
addressFromB:
type: string
type: string

View File

@@ -12,4 +12,4 @@ paths:
$ref: '#/components/responses/responseA'
components:
$ref: './components.yaml'
$ref: './components.yaml'

View File

@@ -3,4 +3,4 @@ properties:
fromA:
type: string
addressFromA:
type: string
type: string

View File

@@ -1,2 +1,2 @@
schemaB:
type: integer
type: integer

View File

@@ -41,8 +41,8 @@ let expect = require('chai').expect,
longPath = path.join(__dirname, BUNDLES_FOLDER + '/longPath'),
schemaCollision = path.join(__dirname, BUNDLES_FOLDER + '/schema_collision_from_responses'),
schemaCollisionWRootComponent = path.join(__dirname, BUNDLES_FOLDER + '/schema_collision_w_root_components'),
nestedExamplesAsValue = path.join(__dirname, BUNDLES_FOLDER + '/nested_examples_as_value'),
referencedProperties = path.join(__dirname, BUNDLES_FOLDER + '/referenced_properties'),
nestedExamplesAsValue = path.join(__dirname, BUNDLES_FOLDER + '/nested_examples_as_value'),
referencedComponents = path.join(__dirname, BUNDLES_FOLDER + '/referenced_components'),
referencedPath = path.join(__dirname, BUNDLES_FOLDER + '/referenced_path'),
referencedPathSchema = path.join(__dirname, BUNDLES_FOLDER + '/paths_schema'),
@@ -2582,6 +2582,7 @@ describe('bundle files method - 3.0', function () {
expect(res.output.specification.version).to.equal('3.0');
expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected);
});
it('Should resolve examples correctly', async function () {
let contentRootFile = fs.readFileSync(example2 + '/another.yml', 'utf8'),
example = fs.readFileSync(example2 + '/example2.yaml', 'utf8'),

View File

@@ -340,9 +340,9 @@ describe('validateSupportedVersion method', function () {
expect(result).to.be.true;
});
it('should return true with version 2.0', function () {
it('should return false with version 2.0', function () {
const result = validateSupportedVersion('2.0');
expect(result).to.be.true;
expect(result).to.be.false;
});
it('should return true with version 3.1', function () {