diff --git a/.eslintrc b/.eslintrc index 5b558deba7..d16e0791d6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -37,7 +37,15 @@ "import/no-unresolved": [ 2, { - "ignore": ["^@swagger-api/apidom-reference/configuration/empty$"] + "ignore": [ + "^@swagger-api/apidom-reference/configuration/empty$", + "^@swagger-api/apidom-reference/dereference/strategies/openapi-3-1$", + "^@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/\\$anchor$", + "^@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/uri$", + "^@swagger-api/apidom-reference/resolve/resolvers/file$", + "^@swagger-api/apidom-reference/resolve/strategies/openapi-3-1$", + "^@swagger-api/apidom-reference/parse/parsers/binary$" + ] } ], "prettier/prettier": "error", diff --git a/config/jest/jest.unit.config.js b/config/jest/jest.unit.config.js index 540015b1d6..1ddaf7e160 100644 --- a/config/jest/jest.unit.config.js +++ b/config/jest/jest.unit.config.js @@ -15,5 +15,7 @@ module.exports = { '/test/jest.setup.js', '/test/specmap/data/', '/test/build-artifacts/', + '/__fixtures__/', + '/__utils__/', ], }; diff --git a/package.json b/package.json index 5c34a6bd1c..478a622670 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "build:es": "cross-env BABEL_ENV=es babel src --out-dir es", "lint": "eslint src/ test/", "lint:fix": "npm run lint -- --fix", + "link:apidom": "npm link @swagger-api/apidom-core @swagger-api/apidom-reference @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-json-pointer", "test": "run-s test:unit:coverage test:artifact", "test:unit": "cross-env BABEL_ENV=commonjs jest --runInBand --config ./config/jest/jest.unit.config.js", "test:unit:coverage": "cross-env BABEL_ENV=commonjs jest --runInBand --config ./config/jest/jest.unit.coverage.config.js", @@ -110,9 +111,10 @@ }, "dependencies": { "@babel/runtime-corejs3": "^7.11.2", - "@swagger-api/apidom-core": "^0.60.0", - "@swagger-api/apidom-reference": "^0.60.0", - "@swagger-api/apidom-ns-openapi-3-1": "^0.60.0", + "@swagger-api/apidom-core": "^0.61.0", + "@swagger-api/apidom-reference": "^0.61.0", + "@swagger-api/apidom-ns-openapi-3-1": "^0.61.0", + "@swagger-api/apidom-json-pointer": "^0.61.0", "cookie": "~0.5.0", "cross-fetch": "^3.1.5", "deepmerge": "~4.2.2", diff --git a/src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js b/src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js new file mode 100644 index 0000000000..ba2816801b --- /dev/null +++ b/src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js @@ -0,0 +1,64 @@ +/* eslint-disable camelcase */ +import { createNamespace, visit } from '@swagger-api/apidom-core'; +import { ReferenceSet, Reference } from '@swagger-api/apidom-reference/configuration/empty'; +import OpenApi3_1DereferenceStrategy from '@swagger-api/apidom-reference/dereference/strategies/openapi-3-1'; +import openApi3_1Namespace, { getNodeType, keyMap } from '@swagger-api/apidom-ns-openapi-3-1'; + +import OpenApi3_1SwaggerClientDereferenceVisitor from './visitor.js'; + +const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')]; + +const OpenApi3_1SwaggerClientDereferenceStrategy = OpenApi3_1DereferenceStrategy.compose({ + props: { + useCircularStructures: true, + allowMetaPatches: false, + }, + init({ + useCircularStructures = this.useCircularStructures, + allowMetaPatches = this.allowMetaPatches, + } = {}) { + this.name = 'openapi-3-1-swagger-client'; + this.useCircularStructures = useCircularStructures; + this.allowMetaPatches = allowMetaPatches; + }, + methods: { + async dereference(file, options) { + const namespace = createNamespace(openApi3_1Namespace); + const refSet = options.dereference.refSet ?? ReferenceSet(); + let reference; + + if (!refSet.has(file.uri)) { + reference = Reference({ uri: file.uri, value: file.parseResult }); + refSet.add(reference); + } else { + // pre-computed refSet was provided as configuration option + reference = refSet.find((ref) => ref.uri === file.uri); + } + + const visitor = OpenApi3_1SwaggerClientDereferenceVisitor({ + reference, + namespace, + options, + useCircularStructures: this.useCircularStructures, + allowMetaPatches: this.allowMetaPatches, + }); + const dereferencedElement = await visitAsync(refSet.rootRef.value, visitor, { + keyMap, + nodeTypeGetter: getNodeType, + }); + + /** + * Release all memory if this refSet was not provided as a configuration option. + * If provided as configuration option, then provider is responsible for cleanup. + */ + if (options.dereference.refSet === null) { + refSet.clean(); + } + + return dereferencedElement; + }, + }, +}); + +export default OpenApi3_1SwaggerClientDereferenceStrategy; +/* eslint-enable camelcase */ diff --git a/src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitor.js b/src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitor.js new file mode 100644 index 0000000000..5e42aca8bc --- /dev/null +++ b/src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitor.js @@ -0,0 +1,444 @@ +/* eslint-disable camelcase */ +import { + isObjectElement, + isPrimitiveElement, + isStringElement, + visit, +} from '@swagger-api/apidom-core'; +import { + isReferenceElementExternal, + isReferenceLikeElement, + isPathItemElementExternal, + isBooleanJsonSchemaElement, + ReferenceElement, + PathItemElement, + SchemaElement, + getNodeType, + keyMap, +} from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate as jsonPointerEvaluate, uriToPointer } from '@swagger-api/apidom-json-pointer'; +import { + url, + MaximumDereferenceDepthError, + File, +} from '@swagger-api/apidom-reference/configuration/empty'; +import { + OpenApi3_1DereferenceVisitor, + resolveSchema$refField, + maybeRefractToSchemaElement, +} from '@swagger-api/apidom-reference/dereference/strategies/openapi-3-1'; +import { + isAnchor, + uriToAnchor, + evaluate as $anchorEvaluate, +} from '@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/$anchor'; +import { + evaluate as uriEvaluate, + EvaluationJsonSchemaUriError, +} from '@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/uri'; + +const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')]; + +const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.compose({ + props: { + useCircularStructures: true, + allowMetaPatches: false, + }, + init({ + visited = { + SchemaElement: new WeakSet(), + SchemaElementReference: new WeakSet(), + SchemaElementNoReference: new WeakSet(), + }, + useCircularStructures, + allowMetaPatches, + }) { + this.visited = visited; + this.useCircularStructures = useCircularStructures; + this.allowMetaPatches = allowMetaPatches; + }, + methods: { + async ReferenceElement(referenceElement) { + // ignore resolving external Reference Objects + if (!this.options.resolve.external && isReferenceElementExternal(referenceElement)) { + return false; + } + + // @ts-ignore + const reference = await this.toReference(referenceElement.$ref.toValue()); + + this.indirections.push(referenceElement); + + const jsonPointer = uriToPointer(referenceElement.$ref?.toValue()); + + // possibly non-semantic fragment + let fragment = jsonPointerEvaluate(jsonPointer, reference.value.result); + + // applying semantics to a fragment + if (isPrimitiveElement(fragment)) { + const referencedElementType = referenceElement.meta.get('referenced-element').toValue(); + + if (isReferenceLikeElement(fragment)) { + // handling indirect references + fragment = ReferenceElement.refract(fragment); + fragment.setMetaProperty('referenced-element', referencedElementType); + } else { + // handling direct references + const ElementClass = this.namespace.getElementClass(referencedElementType); + fragment = ElementClass.refract(fragment); + } + } + + // detect direct or indirect reference + if (this.indirections.includes(fragment)) { + throw new Error('Recursive JSON Pointer detected'); + } + + // detect maximum depth of dereferencing + if (this.indirections.length > this.options.dereference.maxDepth) { + throw new MaximumDereferenceDepthError( + `Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"` + ); + } + + // dive deep into the fragment + const visitor = OpenApi3_1SwaggerClientDereferenceVisitor({ + reference, + namespace: this.namespace, + indirections: [...this.indirections], + options: this.options, + allowMetaPatches: this.allowMetaPatches, + }); + fragment = await visitAsync(fragment, visitor, { keyMap, nodeTypeGetter: getNodeType }); + + fragment = fragment.clone(); + + // annotate fragment with info about original Reference element + fragment.setMetaProperty('ref-fields', { + $ref: referenceElement.$ref?.toValue(), + // @ts-ignore + description: referenceElement.description?.toValue(), + // @ts-ignore + summary: referenceElement.summary?.toValue(), + }); + // annotate fragment with info about origin + fragment.setMetaProperty('ref-origin', reference.uri); + + // override description and summary (outer has higher priority then inner) + const hasDescription = typeof referenceElement.description !== 'undefined'; + const hasSummary = typeof referenceElement.description !== 'undefined'; + if (hasDescription && 'description' in fragment) { + // @ts-ignore + fragment.description = referenceElement.description; + } + if (hasSummary && 'summary' in fragment) { + // @ts-ignore + fragment.summary = referenceElement.summary; + } + + // apply meta patches + if (this.allowMetaPatches && isObjectElement(fragment)) { + const objectFragment = fragment; + // apply meta patch only when not already applied + if (typeof objectFragment.get('$$ref') === 'undefined') { + const absoluteJSONPointerURL = url.resolve( + reference.uri, + referenceElement.$ref?.toValue() + ); + objectFragment.set('$$ref', absoluteJSONPointerURL); + } + } + + this.indirections.pop(); + + // transclude the element for a fragment + return fragment; + }, + + async PathItemElement(pathItemElement) { + // ignore PathItemElement without $ref field + if (!isStringElement(pathItemElement.$ref)) { + return undefined; + } + + // ignore resolving external Path Item Elements + if (!this.options.resolve.external && isPathItemElementExternal(pathItemElement)) { + return undefined; + } + + // @ts-ignore + const reference = await this.toReference(pathItemElement.$ref.toValue()); + + this.indirections.push(pathItemElement); + + const jsonPointer = uriToPointer(pathItemElement.$ref?.toValue()); + + // possibly non-semantic referenced element + let referencedElement = jsonPointerEvaluate(jsonPointer, reference.value.result); + + // applying semantics to a referenced element + if (isPrimitiveElement(referencedElement)) { + referencedElement = PathItemElement.refract(referencedElement); + } + + // detect direct or indirect reference + if (this.indirections.includes(referencedElement)) { + throw new Error('Recursive JSON Pointer detected'); + } + + // detect maximum depth of dereferencing + if (this.indirections.length > this.options.dereference.maxDepth) { + throw new MaximumDereferenceDepthError( + `Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"` + ); + } + + // dive deep into the referenced element + const visitor = OpenApi3_1SwaggerClientDereferenceVisitor({ + reference, + namespace: this.namespace, + indirections: [...this.indirections], + options: this.options, + allowMetaPatches: this.allowMetaPatches, + }); + referencedElement = await visitAsync(referencedElement, visitor, { + keyMap, + nodeTypeGetter: getNodeType, + }); + + this.indirections.pop(); + + // merge fields from referenced Path Item with referencing one + const mergedResult = new PathItemElement( + // @ts-ignore + [...referencedElement.content], + referencedElement.meta.clone(), + referencedElement.attributes.clone() + ); + // existing keywords from referencing PathItemElement overrides ones from referenced element + pathItemElement.forEach((value, key, item) => { + mergedResult.remove(key.toValue()); + mergedResult.content.push(item); + }); + mergedResult.remove('$ref'); + + // annotate referenced element with info about original referencing element + mergedResult.setMetaProperty('ref-fields', { + $ref: pathItemElement.$ref?.toValue(), + }); + // annotate referenced element with info about origin + mergedResult.setMetaProperty('ref-origin', reference.uri); + + // apply meta patches + if (this.allowMetaPatches) { + // apply meta patch only when not already applied + if (typeof mergedResult.get('$$ref') === 'undefined') { + const absoluteJSONPointerURL = url.resolve( + reference.uri, + pathItemElement.$ref?.toValue() + ); + mergedResult.set('$$ref', absoluteJSONPointerURL); + } + } + + // transclude referencing element with merged referenced element + return mergedResult; + }, + + async SchemaElement(referencingElement) { + /** + * Skip traversal for already visited schemas. + * visit function detects cycles in path automatically. + */ + if (this.visited.SchemaElementNoReference.has(referencingElement)) { + return false; + } + if (this.visited.SchemaElementReference.has(referencingElement)) { + return undefined; + } + + // skip current referencing schema as $ref keyword was not defined + if (!isStringElement(referencingElement.$ref)) { + // mark current referencing schema as visited + this.visited.SchemaElement.add(referencingElement); + this.visited.SchemaElementNoReference.add(referencingElement); + // skip traversing this schema but traverse all it's child schemas + return undefined; + } + + // compute baseURI using rules around $id and $ref keywords + const retrieveURI = this.reference.uri; + const $refBaseURI = resolveSchema$refField(retrieveURI, referencingElement); + const $refBaseURIStrippedHash = url.stripHash($refBaseURI); + const file = File({ uri: $refBaseURIStrippedHash }); + const isUnknownURI = !this.options.resolve.resolvers.some((r) => r.canRead(file)); + const isURL = !isUnknownURI; + const isExternal = isURL && this.reference.uri !== $refBaseURIStrippedHash; + + // ignore resolving external Schema Objects + if (!this.options.resolve.external && isExternal) { + // mark current referencing schema as visited + this.visited.SchemaElement.add(referencingElement); + this.visited.SchemaElementReference.add(referencingElement); + // skip traversing this schema but traverse all it's child schemas + return undefined; + } + + this.indirections.push(referencingElement); + + // determining reference, proper evaluation and selection mechanism + let reference; + let referencedElement; + + try { + if (isUnknownURI || isURL) { + // we're dealing with canonical URI or URL with possible fragment + reference = this.reference; + const selector = $refBaseURI; + referencedElement = uriEvaluate( + selector, + // @ts-ignore + maybeRefractToSchemaElement(reference.value.result) + ); + } else { + // we're assuming here that we're dealing with JSON Pointer here + reference = await this.toReference(url.unsanitize($refBaseURI)); + const selector = uriToPointer($refBaseURI); + referencedElement = maybeRefractToSchemaElement( + // @ts-ignore + jsonPointerEvaluate(selector, reference.value.result) + ); + } + } catch (error) { + /** + * No SchemaElement($id=URL) was not found, so we're going to try to resolve + * the URL and assume the returned response is a JSON Schema. + */ + if (isURL && error instanceof EvaluationJsonSchemaUriError) { + if (isAnchor(uriToAnchor($refBaseURI))) { + // we're dealing with JSON Schema $anchor here + reference = await this.toReference(url.unsanitize($refBaseURI)); + const selector = uriToAnchor($refBaseURI); + referencedElement = $anchorEvaluate( + selector, + // @ts-ignore + maybeRefractToSchemaElement(reference.value.result) + ); + } else { + // we're assuming here that we're dealing with JSON Pointer here + reference = await this.toReference(url.unsanitize($refBaseURI)); + const selector = uriToPointer($refBaseURI); + referencedElement = maybeRefractToSchemaElement( + // @ts-ignore + jsonPointerEvaluate(selector, reference.value.result) + ); + } + } else { + throw error; + } + } + + // mark current referencing schema as visited + this.visited.SchemaElement.add(referencingElement); + this.visited.SchemaElementReference.add(referencingElement); + + // detect direct or indirect reference + if (this.indirections.includes(referencedElement)) { + throw new Error('Recursive JSON Pointer detected'); + } + + // detect maximum depth of dereferencing + if (this.indirections.length > this.options.dereference.maxDepth) { + throw new MaximumDereferenceDepthError( + `Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"` + ); + } + + // detect possible cycle and avoid it + if (!this.useCircularStructures && this.visited.SchemaElement.has(referencedElement)) { + if (url.isHttpUrl(reference.uri) || url.isFileSystemPath(reference.uri)) { + // make the referencing URL or file system path absolute + const absoluteJSONPointerURL = url.resolve( + reference.uri, + referencingElement.$ref?.toValue() + ); + referencingElement.set('$ref', absoluteJSONPointerURL); + } + // skip processing this schema and all it's child schemas + return false; + } + + // dive deep into the fragment + const visitor = OpenApi3_1SwaggerClientDereferenceVisitor({ + reference, + namespace: this.namespace, + indirections: [...this.indirections], + options: this.options, + // SchemaElementReference must be reset for deep dive, as we want to dereference all indirections + visited: { + SchemaElement: this.visited.SchemaElement, + SchemaElementReference: new WeakSet(), + SchemaElementNoReference: this.visited.SchemaElementNoReference, + }, + useCircularStructures: this.useCircularStructures, + allowMetaPatches: this.allowMetaPatches, + }); + referencedElement = await visitAsync(referencedElement, visitor, { + keyMap, + nodeTypeGetter: getNodeType, + }); + + this.indirections.pop(); + + // Boolean JSON Schemas + if (isBooleanJsonSchemaElement(referencedElement)) { + const referencedElementClone = referencedElement.clone(); + // annotate referenced element with info about original referencing element + referencedElementClone.setMetaProperty('ref-fields', { + $ref: referencingElement.$ref?.toValue(), + }); + // annotate referenced element with info about origin + referencedElementClone.setMetaProperty('ref-origin', reference.uri); + return referencedElementClone; + } + + // Schema Object - merge keywords from referenced schema with referencing schema + const mergedResult = new SchemaElement( + // @ts-ignore + [...referencedElement.content], + referencedElement.meta.clone(), + referencedElement.attributes.clone() + ); + // existing keywords from referencing schema overrides ones from referenced schema + referencingElement.forEach((value, key, item) => { + mergedResult.remove(key.toValue()); + mergedResult.content.push(item); + }); + mergedResult.remove('$ref'); + + // annotate referenced element with info about original referencing element + mergedResult.setMetaProperty('ref-fields', { + $ref: referencingElement.$ref?.toValue(), + }); + // annotate fragment with info about origin + mergedResult.setMetaProperty('ref-origin', reference.uri); + // apply meta patches + if (this.allowMetaPatches) { + // apply meta patch only when not already applied + if (typeof mergedResult.get('$$ref') === 'undefined') { + const absoluteJSONPointerURL = url.resolve( + reference.uri, + referencingElement.$ref?.toValue() + ); + mergedResult.set('$$ref', absoluteJSONPointerURL); + } + } + + // transclude referencing element with merged referenced element + return mergedResult; + }, + }, +}); + +export default OpenApi3_1SwaggerClientDereferenceVisitor; +/* eslint-enable camelcase */ diff --git a/src/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js b/src/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js index ae282d1a4b..16801b38a4 100644 --- a/src/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js +++ b/src/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js @@ -7,7 +7,6 @@ import { OpenAPIMediaTypes, } from '@swagger-api/apidom-ns-openapi-3-1'; -// eslint-disable-next-line camelcase const OpenApiJson3_1Parser = Parser.compose({ props: { name: 'openapi-json-3-1-swagger-client', diff --git a/src/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js b/src/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js index 55174ba7e3..bf5efa79e8 100644 --- a/src/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js +++ b/src/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js @@ -8,7 +8,6 @@ import { OpenAPIMediaTypes, } from '@swagger-api/apidom-ns-openapi-3-1'; -// eslint-disable-next-line camelcase const OpenApiYaml3_1Parser = Parser.compose({ props: { name: 'openapi-yaml-3-1-swagger-client', diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/__utils__/jest.local.setup.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/__utils__/jest.local.setup.js new file mode 100644 index 0000000000..5924ad7487 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/__utils__/jest.local.setup.js @@ -0,0 +1,40 @@ +/* eslint-disable camelcase */ +import { options } from '@swagger-api/apidom-reference/configuration/empty'; +import FileResolver from '@swagger-api/apidom-reference/resolve/resolvers/file'; +import BinaryParser from '@swagger-api/apidom-reference/parse/parsers/binary'; +import OpenApi3_1ResolveStrategy from '@swagger-api/apidom-reference/resolve/strategies/openapi-3-1'; + +import JsonParser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/json/index.js'; +import YamlParser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/yaml-1-2/index.js'; +import OpenApiJson3_1Parser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js'; +import OpenApiYaml3_1Parser from '../../../../../../../../src/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js'; +import HttpResolverSwaggerClient from '../../../../../../../../src/helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js'; +import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js'; + +export const beforeAll = () => { + // configure custom parser plugins globally + options.parse.parsers = [ + OpenApiJson3_1Parser({ allowEmpty: false, sourceMap: false }), + OpenApiYaml3_1Parser({ allowEmpty: false, sourceMap: false }), + JsonParser({ allowEmpty: false, sourceMap: false }), + YamlParser({ allowEmpty: false, sourceMap: false }), + BinaryParser({ allowEmpty: false, sourceMap: false }), + ]; + + // configure custom resolver plugins globally + options.resolve.resolvers = [FileResolver({ fileAllowList: ['*'] }), HttpResolverSwaggerClient()]; + + // configure custom resolver strategies globally + options.resolve.strategies = [OpenApi3_1ResolveStrategy()]; + + // configure custom dereference strategy globally + options.dereference.strategies = [OpenApi3_1SwaggerClientDereferenceStrategy()]; +}; + +export const afterAll = () => { + options.parse.parsers = []; + options.resolve.resolvers = []; + options.resolve.strategies = []; + options.dereference.strategies = []; +}; +/* eslint-enable camelcase */ diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/components-callbacks/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/components-callbacks/dereferenced.json new file mode 100644 index 0000000000..4c753eb15c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/components-callbacks/dereferenced.json @@ -0,0 +1,19 @@ +[ + { + "openapi": "3.1.0", + "components": { + "callbacks": { + "callback1": { + "{$method}": { + "description": "description of callback2" + } + }, + "callback2": { + "{$method}": { + "description": "description of callback2" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/components-callbacks/root.yaml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/components-callbacks/root.yaml new file mode 100644 index 0000000000..93fff754fe --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/components-callbacks/root.yaml @@ -0,0 +1,9 @@ +--- +openapi: 3.1.0 +components: + callbacks: + callback1: + "$ref": "#/components/callbacks/callback2" + callback2: + "{$method}": + description: description of callback2 diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/operation-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/operation-object/dereferenced.json new file mode 100644 index 0000000000..9bdc71acaf --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/operation-object/dereferenced.json @@ -0,0 +1,27 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "callbacks": { + "callback": { + "{$method}": { + "description": "description of callback2" + } + } + } + } + } + }, + "components": { + "callbacks": { + "callback": { + "{$method}": { + "description": "description of callback2" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/operation-object/root.yaml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/operation-object/root.yaml new file mode 100644 index 0000000000..0c9162d0f1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/__fixtures__/operation-object/root.yaml @@ -0,0 +1,13 @@ +--- +openapi: 3.1.0 +paths: + "/path": + get: + callbacks: + callback: + "$ref": "#/components/callbacks/callback" +components: + callbacks: + callback: + "{$method}": + description: description of callback2 diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/index.js new file mode 100644 index 0000000000..43ab500cba --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/callback-object/index.js @@ -0,0 +1,52 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Callback Object', () => { + describe('given in components/callbacks field', () => { + const fixturePath = path.join(rootFixturePath, 'components-callbacks'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.yaml'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('yaml') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Operation Object', () => { + const fixturePath = path.join(rootFixturePath, 'operation-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.yaml'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('yaml') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/components-examples/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/components-examples/dereferenced.json new file mode 100644 index 0000000000..810362c752 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/components-examples/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": 1 + }, + "example2": { + "description": "example1 description", + "value": 1 + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/components-examples/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/components-examples/root.json new file mode 100644 index 0000000000..d7f47b7b3a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/components-examples/root.json @@ -0,0 +1,14 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": 1 + }, + "example2": { + "$ref": "#/components/examples/example1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/dereferenced.json new file mode 100644 index 0000000000..6390964608 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/dereferenced.json @@ -0,0 +1,14 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": "AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAKBEAAJ4EAAAwMAAAAQAgAGgmAADGFQAAKAAAABAAAAAgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOPj4//j4+P/4+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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "externalValue": "./favicon.ico" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/favicon.ico b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/favicon.ico new file mode 100644 index 0000000000..4ffa222883 Binary files /dev/null and b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/favicon.ico differ diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/root.json new file mode 100644 index 0000000000..8179437c62 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-binary/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./favicon.ico" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/dereferenced.json new file mode 100644 index 0000000000..c04d231350 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/dereferenced.json @@ -0,0 +1,13 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.json" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/ex.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/ex.json @@ -0,0 +1 @@ +{} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/root.json new file mode 100644 index 0000000000..2c2d58d639 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-ignore-external/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.json" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/dereferenced.json new file mode 100644 index 0000000000..a5cff2bc14 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": { + "prop1": "value1", + "prop2": "value2" + }, + "externalValue": "./ex.json" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/ex.json new file mode 100644 index 0000000000..6fb8855f8a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/ex.json @@ -0,0 +1,4 @@ +{ + "prop1": "value1", + "prop2": "value2" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/root.json new file mode 100644 index 0000000000..2c2d58d639 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-json/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.json" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/dereferenced.json new file mode 100644 index 0000000000..eae84b99b7 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": { + "prop1": "value1", + "prop2": "value2" + }, + "externalValue": "./ex.json#/json/pointer" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/ex.json new file mode 100644 index 0000000000..6fb8855f8a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/ex.json @@ -0,0 +1,4 @@ +{ + "prop1": "value1", + "prop2": "value2" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/root.json new file mode 100644 index 0000000000..e5e5883e48 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-pointer/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.json#/json/pointer" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/dereferenced.json new file mode 100644 index 0000000000..ce48fb16f1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/dereferenced.json @@ -0,0 +1,14 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": "dmFsMTt2YWwyO3ZhbDMK", + "externalValue": "./ex.csv" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/ex.csv b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/ex.csv new file mode 100644 index 0000000000..afd194d0e1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/ex.csv @@ -0,0 +1 @@ +val1;val2;val3 diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/root.json new file mode 100644 index 0000000000..fb347a7767 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-text/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.csv" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-unresolvable/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-unresolvable/root.json new file mode 100644 index 0000000000..2c2d58d639 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-unresolvable/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.json" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-value-both-defined/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-value-both-defined/ex.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-value-both-defined/ex.json @@ -0,0 +1 @@ +{} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-value-both-defined/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-value-both-defined/root.json new file mode 100644 index 0000000000..a63d5e606f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-value-both-defined/root.json @@ -0,0 +1,12 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": "sample value", + "externalValue": "./ex.json" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/dereferenced.json new file mode 100644 index 0000000000..1ad8645745 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "value": { + "prop1": "value1", + "prop2": "value2" + }, + "externalValue": "./ex.yaml" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/ex.yaml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/ex.yaml new file mode 100644 index 0000000000..95d4e79f9c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/ex.yaml @@ -0,0 +1,3 @@ +--- +prop1: value1 +prop2: value2 diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/root.json new file mode 100644 index 0000000000..54aa18bb2f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/external-value-yaml/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "examples": { + "example1": { + "description": "example1 description", + "externalValue": "./ex.yaml" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/media-type-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/media-type-object/dereferenced.json new file mode 100644 index 0000000000..393ed725de --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/media-type-object/dereferenced.json @@ -0,0 +1,31 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "responses": { + "201": { + "content": { + "application/json": { + "examples": { + "example1": { + "description": "example 2 description" + } + } + } + } + } + } + } + } + }, + "components": { + "examples": { + "example2": { + "description": "example 2 description" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/media-type-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/media-type-object/root.json new file mode 100644 index 0000000000..d1b8222953 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/media-type-object/root.json @@ -0,0 +1,29 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "responses": { + "201": { + "content": { + "application/json": { + "examples": { + "example1": { + "$ref": "#/components/examples/example2" + } + } + } + } + } + } + } + } + }, + "components": { + "examples": { + "example2": { + "description": "example 2 description" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/parameter-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/parameter-object/dereferenced.json new file mode 100644 index 0000000000..27d46beaae --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/parameter-object/dereferenced.json @@ -0,0 +1,24 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true, + "examples": { + "example1": { + "description": "example 2 description" + } + } + } + }, + "examples": { + "example2": { + "description": "example 2 description" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/parameter-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/parameter-object/root.json new file mode 100644 index 0000000000..1ba502d046 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/__fixtures__/parameter-object/root.json @@ -0,0 +1,22 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true, + "examples": { + "example1": { + "$ref": "#/components/examples/example2" + } + } + } + }, + "examples": { + "example2": { + "description": "example 2 description" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/dereference-apidom.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/dereference-apidom.js new file mode 100644 index 0000000000..22ad6420ac --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/dereference-apidom.js @@ -0,0 +1,59 @@ +import path from 'node:path'; +import { mediaTypes, isExampleElement } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { parse, dereferenceApiDOM } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Example Object', () => { + describe('given single ExampleElement passed to dereferenceApiDOM', () => { + const fixturePath = path.join( + __dirname, + '__fixtures__', + 'external-value-json', + 'root.json' + ); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const exampleElement = evaluate('/components/examples/example1', parseResult.api); + const dereferenced = await dereferenceApiDOM(exampleElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(isExampleElement(dereferenced)).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const exampleElement = evaluate('/components/examples/example1', parseResult.api); + const dereferenced = await dereferenceApiDOM(exampleElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(dereferenced.value?.meta.get('ref-origin').toValue()).toEqual( + expect.stringMatching(/external-value-json\/ex\.json$/) + ); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/index.js new file mode 100644 index 0000000000..a9c87e149e --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/example-object/index.js @@ -0,0 +1,181 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference, DereferenceError } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Example Object', () => { + describe('given in components/examples field', () => { + const fixturePath = path.join(rootFixturePath, 'components-examples'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Parameter Object', () => { + const fixturePath = path.join(rootFixturePath, 'parameter-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Media Type Object', () => { + const fixturePath = path.join(rootFixturePath, 'media-type-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given externalValue field', () => { + describe('and pointing to a JSON file', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-json'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('and pointing to a JSON file and having JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-pointer'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('and pointing to a YAML file', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-yaml'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('and pointing to a text file', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-text'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('and pointing to a binary file', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-binary'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('and with unresolvable URI', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-unresolvable'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('with external resolution disabled', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-ignore-external'); + + test('should not dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { external: false }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given both value and externalValue fields are defined', () => { + const fixturePath = path.join(rootFixturePath, 'external-value-value-both-defined'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/components-headers/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/components-headers/dereferenced.json new file mode 100644 index 0000000000..83fecb62ce --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/components-headers/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "headers": { + "content-type": { + "description": "content type header description" + }, + "x-custom-header": { + "description": "content type header description" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/components-headers/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/components-headers/root.json new file mode 100644 index 0000000000..fe69f04fea --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/components-headers/root.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.1.0", + "components": { + "headers": { + "content-type": { + "description": "content type header description" + }, + "x-custom-header": { + "$ref": "#/components/headers/content-type" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/encoding-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/encoding-object/dereferenced.json new file mode 100644 index 0000000000..33a788b7fe --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/encoding-object/dereferenced.json @@ -0,0 +1,32 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true, + "content": { + "encoding": { + "Encoding": { + "headers": { + "content-type": { + "$ref": "#/components/headers/content-type" + } + } + } + } + } + } + }, + "components": { + "headers": { + "content-type": { + "description": "content type header description" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/encoding-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/encoding-object/root.json new file mode 100644 index 0000000000..e3d771e9e6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/encoding-object/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true, + "content": { + "encoding": { + "Encoding": { + "headers": { + "content-type": { + "$ref": "#/components/headers/content-type" + } + } + } + } + } + } + }, + "components": { + "headers": { + "content-type": { + "description": "content type header description" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/response-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/response-object/dereferenced.json new file mode 100644 index 0000000000..ddf6b31709 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/response-object/dereferenced.json @@ -0,0 +1,21 @@ +[ + { + "openapi": "3.1.0", + "components": { + "responses": { + "default": { + "headers": { + "content-type": { + "description": "content type header description" + } + } + } + }, + "headers": { + "content-type": { + "description": "content type header description" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/response-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/response-object/root.json new file mode 100644 index 0000000000..c41ada395a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/__fixtures__/response-object/root.json @@ -0,0 +1,19 @@ +{ + "openapi": "3.1.0", + "components": { + "responses": { + "default": { + "headers": { + "content-type": { + "$ref": "#/components/headers/content-type" + } + } + } + }, + "headers": { + "content-type": { + "description": "content type header description" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/index.js new file mode 100644 index 0000000000..3ec8e8774d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/header-object/index.js @@ -0,0 +1,66 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Header Object', () => { + describe('given in components/headers field', () => { + const fixturePath = path.join(rootFixturePath, 'components-headers'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Encoding Object', () => { + const fixturePath = path.join(rootFixturePath, 'encoding-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Response Object', () => { + const fixturePath = path.join(rootFixturePath, 'response-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/components-links/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/components-links/dereferenced.json new file mode 100644 index 0000000000..15e6146695 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/components-links/dereferenced.json @@ -0,0 +1,22 @@ +[ + { + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationId": "op1" + }, + "link2": { + "operationId": "op1" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "operationId": "op1" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/components-links/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/components-links/root.json new file mode 100644 index 0000000000..1503044b06 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/components-links/root.json @@ -0,0 +1,20 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationId": "op1" + }, + "link2": { + "$ref": "#/components/links/link1" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "operationId": "op1" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id-non-existent/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id-non-existent/root.json new file mode 100644 index 0000000000..3d24df3526 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id-non-existent/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationId": "op1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id/dereferenced.json new file mode 100644 index 0000000000..54b33ce516 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id/dereferenced.json @@ -0,0 +1,20 @@ +[ + { + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationId": "op1" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "operationId": "op1", + "description": "description of operation" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id/root.json new file mode 100644 index 0000000000..45a7f2b541 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-id/root.json @@ -0,0 +1,18 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationId": "op1" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "operationId": "op1", + "description": "description of operation" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/dereferenced.json new file mode 100644 index 0000000000..c8ccfd0370 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/dereferenced.json @@ -0,0 +1,12 @@ +[ + { + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "./ex.json#/operation" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/ex.json new file mode 100644 index 0000000000..3d6eb5ad85 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/ex.json @@ -0,0 +1,5 @@ +{ + "operation": { + "description": "description of operation" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/root.json new file mode 100644 index 0000000000..76e6167168 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-external/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "./ex.json#/operation" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-id-both-defined/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-id-both-defined/root.json new file mode 100644 index 0000000000..78b2af181a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-id-both-defined/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "#/components/pathItems/pathItem1/get", + "operationId": "op1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/dereferenced.json new file mode 100644 index 0000000000..c8ccfd0370 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/dereferenced.json @@ -0,0 +1,12 @@ +[ + { + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "./ex.json#/operation" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/ex.json new file mode 100644 index 0000000000..3d6eb5ad85 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/ex.json @@ -0,0 +1,5 @@ +{ + "operation": { + "description": "description of operation" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/root.json new file mode 100644 index 0000000000..76e6167168 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-ignore-external/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "./ex.json#/operation" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-internal/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-internal/dereferenced.json new file mode 100644 index 0000000000..11d3b1a74f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-internal/dereferenced.json @@ -0,0 +1,19 @@ +[ + { + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "#/components/pathItems/pathItem1/get" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "description": "description of operation" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-internal/root.json new file mode 100644 index 0000000000..e91b65104d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-internal/root.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "#/components/pathItems/pathItem1/get" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "description": "description of operation" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-invalid-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-invalid-pointer/root.json new file mode 100644 index 0000000000..2da69bb325 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-invalid-pointer/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "invalid-pointer" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-unresolvable/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-unresolvable/root.json new file mode 100644 index 0000000000..3b24ce87df --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/operation-ref-unresolvable/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "links": { + "link1": { + "operationRef": "#/components/invalid-pointer" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/response-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/response-object/dereferenced.json new file mode 100644 index 0000000000..de73b5e73c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/response-object/dereferenced.json @@ -0,0 +1,29 @@ +[ + { + "openapi": "3.1.0", + "components": { + "responses": { + "201": { + "description": "201 description", + "links": { + "link": { + "operationId": "op1" + } + } + } + }, + "links": { + "link1": { + "operationId": "op1" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "operationId": "op1" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/response-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/response-object/root.json new file mode 100644 index 0000000000..40cebbda47 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/__fixtures__/response-object/root.json @@ -0,0 +1,27 @@ +{ + "openapi": "3.1.0", + "components": { + "responses": { + "201": { + "description": "201 description", + "links": { + "link": { + "$ref": "#/components/links/link1" + } + } + } + }, + "links": { + "link1": { + "operationId": "op1" + } + }, + "pathItems": { + "pathItem1": { + "get": { + "operationId": "op1" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/dereference-apidom.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/dereference-apidom.js new file mode 100644 index 0000000000..12ca25a9dd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/dereference-apidom.js @@ -0,0 +1,60 @@ +import path from 'node:path'; +import { mediaTypes, isLinkElement, isOperationElement } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { parse, dereferenceApiDOM } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Link Object', () => { + describe('given single LinkElement passed to dereferenceApiDOM', () => { + const fixturePath = path.join( + __dirname, + '__fixtures__', + 'operation-ref-external', + 'root.json' + ); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const linkElement = evaluate('/components/links/link1', parseResult.api); + const dereferenced = await dereferenceApiDOM(linkElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(isLinkElement(dereferenced)).toBe(true); + expect(isOperationElement(dereferenced.operationRef?.meta.get('operation'))).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const linkElement = evaluate('/components/links/link1', parseResult.api); + const dereferenced = await dereferenceApiDOM(linkElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect( + dereferenced.operationRef?.meta.get('operation').meta.get('ref-origin').toValue() + ).toEqual(expect.stringMatching(/operation-ref-external\/ex\.json$/)); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/index.js new file mode 100644 index 0000000000..fbf65e41ba --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/link-object/index.js @@ -0,0 +1,236 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { isOperationElement, mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { dereference, DereferenceError } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Link Object', () => { + describe('given in components/links field', () => { + const fixturePath = path.join(rootFixturePath, 'components-links'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should set Operation Object as metadata of Link.operationId field', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const link1 = evaluate('/0/components/links/link1', dereferenced); + const link2 = evaluate('/0/components/links/link2', dereferenced); + + expect(isOperationElement(link1.operationId?.meta.get('operation'))).toBe(true); + expect(isOperationElement(link2.operationId?.meta.get('operation'))).toBe(true); + }); + }); + + describe('given in Response Object', () => { + const fixturePath = path.join(rootFixturePath, 'response-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should set Operation Object as metadata of Link.operationId field', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const link1 = evaluate('/0/components/responses/201/links/link', dereferenced); + const link2 = evaluate('/0/components/links/link1', dereferenced); + + expect(isOperationElement(link1.operationId?.meta.get('operation'))).toBe(true); + expect(isOperationElement(link2.operationId?.meta.get('operation'))).toBe(true); + }); + }); + + describe('given operationRef field', () => { + describe('and with internal JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'operation-ref-internal'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should set Operation Object as metadata of Link.operationRef field', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const link1 = evaluate('/0/components/links/link1', dereferenced); + + expect(isOperationElement(link1.operationRef?.meta.get('operation'))).toBe(true); + }); + }); + + describe('and with external JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'operation-ref-external'); + const rootFilePath = path.join(fixturePath, 'root.json'); + + test('should dereference', async () => { + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should apply semantics to external fragment', async () => { + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + expect( + isOperationElement(dereferenced.api.components.links.get('link1').operation) + ).toBe(true); + }); + + test('should set Operation Object as metadata of Link.operationRef field', async () => { + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const link1 = evaluate('/0/components/links/link1', dereferenced); + + expect(isOperationElement(link1.operationRef?.meta.get('operation'))).toBe(true); + }); + }); + + describe('with external resolution disabled', () => { + const fixturePath = path.join(rootFixturePath, 'operation-ref-ignore-external'); + + test('should not dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { external: false }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('and with invalid JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'operation-ref-invalid-pointer'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('and with unresolvable JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'operation-ref-unresolvable'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + }); + + describe('given operationId field', () => { + describe('and OperationElement with operationId exists', () => { + const fixturePath = path.join(rootFixturePath, 'operation-id'); + const rootFilePath = path.join(fixturePath, 'root.json'); + + test('should dereference', async () => { + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should set Operation Object as metadata of Link.operationId field', async () => { + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const link1 = evaluate('/0/components/links/link1', dereferenced); + + expect(isOperationElement(link1.operationId?.meta.get('operation'))).toBe(true); + }); + }); + + describe("and OperationElement with operationId doesn't exist", () => { + const fixturePath = path.join(rootFixturePath, 'operation-id-non-existent'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + }); + + describe('given both operationRef and operationId fields are defined', () => { + const fixturePath = path.join(rootFixturePath, 'operation-ref-id-both-defined'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + 'LinkElement operationRef and operationId fields are mutually exclusive.' + ); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/components-parameters/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/components-parameters/dereferenced.json new file mode 100644 index 0000000000..2c916faa64 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/components-parameters/dereferenced.json @@ -0,0 +1,19 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true + }, + "param2": { + "name": "offset", + "in": "query", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/components-parameters/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/components-parameters/root.json new file mode 100644 index 0000000000..e6601b6f18 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/components-parameters/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true + }, + "param2": { + "$ref": "#/components/parameters/param1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/operation-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/operation-object/dereferenced.json new file mode 100644 index 0000000000..e9fe33b1bf --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/operation-object/dereferenced.json @@ -0,0 +1,27 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "parameters": [ + { + "name": "offset", + "in": "query", + "required": true + } + ] + } + } + }, + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/operation-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/operation-object/root.json new file mode 100644 index 0000000000..f17d04e46b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/operation-object/root.json @@ -0,0 +1,23 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "parameters": [ + { + "$ref": "#/components/parameters/param1" + } + ] + } + } + }, + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/path-item-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/path-item-object/dereferenced.json new file mode 100644 index 0000000000..7258f817b0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/path-item-object/dereferenced.json @@ -0,0 +1,25 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path": { + "parameters": [ + { + "name": "offset", + "in": "query", + "required": true + } + ] + } + }, + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/path-item-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/path-item-object/root.json new file mode 100644 index 0000000000..280da6ecde --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/__fixtures__/path-item-object/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path": { + "parameters": [ + { + "$ref": "#/components/parameters/param1" + } + ] + } + }, + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/index.js new file mode 100644 index 0000000000..19ac64f27e --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/parameter-object/index.js @@ -0,0 +1,66 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Parameter Object', () => { + describe('given in components/parameters field', () => { + const fixturePath = path.join(rootFixturePath, 'components-parameters'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Path Item Object', () => { + const fixturePath = path.join(rootFixturePath, 'path-item-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Operation Object', () => { + const fixturePath = path.join(rootFixturePath, 'operation-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/additional-fields/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/additional-fields/dereferenced.json new file mode 100644 index 0000000000..3d0e6b4ed1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/additional-fields/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "summary": "path1 item summary", + "description": "path item description", + "get": {} + }, + "/path2": { + "summary": "path2 item summary", + "description": "path item description", + "get": {} + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/additional-fields/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/additional-fields/root.json new file mode 100644 index 0000000000..a49cbf0e5f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/additional-fields/root.json @@ -0,0 +1,14 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "#/paths/~1path2", + "summary": "path1 item summary" + }, + "/path2": { + "summary": "path2 item summary", + "description": "path item description", + "get": {} + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/callback-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/callback-object/dereferenced.json new file mode 100644 index 0000000000..4c753eb15c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/callback-object/dereferenced.json @@ -0,0 +1,19 @@ +[ + { + "openapi": "3.1.0", + "components": { + "callbacks": { + "callback1": { + "{$method}": { + "description": "description of callback2" + } + }, + "callback2": { + "{$method}": { + "description": "description of callback2" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/callback-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/callback-object/root.json new file mode 100644 index 0000000000..20b09ffb6b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/callback-object/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "callbacks": { + "callback1": { + "$ref": "#/components/callbacks/callback2" + }, + "callback2": { + "{$method}": { + "description": "description of callback2" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/components-path-items/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/components-path-items/dereferenced.json new file mode 100644 index 0000000000..b254953a38 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/components-path-items/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "pathItems": { + "pathItem1": { + "description": "description of path item 1" + }, + "pathItem2": { + "description": "description of path item 1" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/components-path-items/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/components-path-items/root.json new file mode 100644 index 0000000000..6c51ddca2c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/components-path-items/root.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.1.0", + "components": { + "pathItems": { + "pathItem1": { + "description": "description of path item 1" + }, + "pathItem2": { + "$ref": "#/components/pathItems/pathItem1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-external-circular/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-external-circular/ex.json new file mode 100644 index 0000000000..4d55709987 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-external-circular/ex.json @@ -0,0 +1,3 @@ +{ + "$ref": "./root.json#/paths/~1path1" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-external-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-external-circular/root.json new file mode 100644 index 0000000000..7850ce66b6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-external-circular/root.json @@ -0,0 +1,8 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-internal-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-internal-circular/root.json new file mode 100644 index 0000000000..c727e272f0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/direct-internal-circular/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "#/paths/~1path2" + }, + "/path2": { + "$ref": "#/paths/~1path1" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/dereferenced.json new file mode 100644 index 0000000000..8f02538ef6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/dereferenced.json @@ -0,0 +1,12 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/ex1.json new file mode 100644 index 0000000000..d7b3e3be55 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/ex1.json @@ -0,0 +1,3 @@ +{ + "$ref": "./ex2.json#/~1path3" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/ex2.json new file mode 100644 index 0000000000..e6d9558407 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/ex2.json @@ -0,0 +1,7 @@ +{ + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/root.json new file mode 100644 index 0000000000..5557004334 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-indirections/root.json @@ -0,0 +1,8 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex1.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/dereferenced.json new file mode 100644 index 0000000000..8f02538ef6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/dereferenced.json @@ -0,0 +1,12 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/ex.json new file mode 100644 index 0000000000..da09224581 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/ex.json @@ -0,0 +1,7 @@ +{ + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/root.json new file mode 100644 index 0000000000..5843b01245 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/external-only/root.json @@ -0,0 +1,8 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex.json#/~1path2" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/dereferenced.json new file mode 100644 index 0000000000..dde8e5a6a8 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/dereferenced.json @@ -0,0 +1,10 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex.json#/~1path2" + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/ex.json new file mode 100644 index 0000000000..da09224581 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/ex.json @@ -0,0 +1,7 @@ +{ + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/root.json new file mode 100644 index 0000000000..5843b01245 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/ignore-external/root.json @@ -0,0 +1,8 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex.json#/~1path2" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/ex1.json new file mode 100644 index 0000000000..8e49d4768f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/ex1.json @@ -0,0 +1,3 @@ +{ + "$ref": "./ex2.json" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/ex2.json new file mode 100644 index 0000000000..4d55709987 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/ex2.json @@ -0,0 +1,3 @@ +{ + "$ref": "./root.json#/paths/~1path1" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/root.json new file mode 100644 index 0000000000..5557004334 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-external-circular/root.json @@ -0,0 +1,8 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex1.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-internal-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-internal-circular/root.json new file mode 100644 index 0000000000..16c0928aa1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/indirect-internal-circular/root.json @@ -0,0 +1,14 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "#/paths/~1path2" + }, + "/path2": { + "$ref": "#/paths/~1path3" + }, + "/path3": { + "$ref": "#/paths/~1path1" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/dereferenced.json new file mode 100644 index 0000000000..a84c3aa600 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/dereferenced.json @@ -0,0 +1,22 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "summary": "path item summary", + "description": "path item description", + "get": {} + }, + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + }, + "/path4": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/ex.json new file mode 100644 index 0000000000..da09224581 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/ex.json @@ -0,0 +1,7 @@ +{ + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/root.json new file mode 100644 index 0000000000..71d688c0be --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-external/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex.json#/~1path2" + }, + "/path3": { + "$ref": "#/paths/~1path4" + }, + "/path4": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-indirections/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-indirections/dereferenced.json new file mode 100644 index 0000000000..417a402ed3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-indirections/dereferenced.json @@ -0,0 +1,22 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "summary": "path item summary", + "description": "path item description", + "get": {} + }, + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + }, + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-indirections/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-indirections/root.json new file mode 100644 index 0000000000..bf154cb3e5 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-indirections/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "#/paths/~1path2" + }, + "/path2": { + "$ref": "#/paths/~1path3" + }, + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-only/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-only/dereferenced.json new file mode 100644 index 0000000000..417a402ed3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-only/dereferenced.json @@ -0,0 +1,22 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path1": { + "summary": "path item summary", + "description": "path item description", + "get": {} + }, + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + }, + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-only/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-only/root.json new file mode 100644 index 0000000000..bf154cb3e5 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/internal-only/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "#/paths/~1path2" + }, + "/path2": { + "$ref": "#/paths/~1path3" + }, + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/invalid-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/invalid-pointer/root.json new file mode 100644 index 0000000000..8d4df81c5d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/invalid-pointer/root.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "invalid-pointer" + }, + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/ex1.json new file mode 100644 index 0000000000..d7b3e3be55 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/ex1.json @@ -0,0 +1,3 @@ +{ + "$ref": "./ex2.json#/~1path3" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/ex2.json new file mode 100644 index 0000000000..e6d9558407 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/ex2.json @@ -0,0 +1,7 @@ +{ + "/path3": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/root.json new file mode 100644 index 0000000000..5557004334 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/max-depth/root.json @@ -0,0 +1,8 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "./ex1.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/dereferenced.json new file mode 100644 index 0000000000..3cfa9cf6f2 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/dereferenced.json @@ -0,0 +1,14 @@ +[ + { + "openapi": "3.1.0", + "components": { + "pathItems": { + "externalRef": { + "description": "external ref", + "get": {}, + "$$ref": "http://localhost:8123/ex3.json#/externalPathItem" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex2.json new file mode 100644 index 0000000000..5d5e2e2955 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/externalPathItem" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex3.json new file mode 100644 index 0000000000..08774eea34 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/ex3.json @@ -0,0 +1,6 @@ +{ + "externalPathItem": { + "description": "this is path item stored in external file", + "get": {} + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/root.json new file mode 100644 index 0000000000..0601253768 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-external/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "pathItems": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-internal/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-internal/dereferenced.json new file mode 100644 index 0000000000..3a4375cef0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-internal/dereferenced.json @@ -0,0 +1,23 @@ +[ + { + "openapi": "3.1.0", + "components": { + "pathItems": { + "pathItem1": { + "summary": "path item summary", + "description": "path item description", + "$$ref": "http://localhost:8123/root.json#/components/pathItems/pathItem3" + }, + "pathItem2": { + "summary": "path item summary", + "description": "path item description", + "$$ref": "http://localhost:8123/root.json#/components/pathItems/pathItem3" + }, + "pathItem3": { + "summary": "path item summary", + "description": "path item description" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-internal/root.json new file mode 100644 index 0000000000..b745848015 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/meta-patches-internal/root.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "components": { + "pathItems": { + "pathItem1": { + "$ref": "#/components/pathItems/pathItem2" + }, + "pathItem2": { + "$ref": "#/components/pathItems/pathItem3" + }, + "pathItem3": { + "summary": "path item summary", + "description": "path item description" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/unresolvable-path-item/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/unresolvable-path-item/root.json new file mode 100644 index 0000000000..1f7c6dcf9b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/unresolvable-path-item/root.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path1": { + "$ref": "#/paths/invalid-pointer" + }, + "/path2": { + "summary": "path item summary", + "description": "path item description", + "get": {} + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/webhooks/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/webhooks/dereferenced.json new file mode 100644 index 0000000000..bda44d5d11 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/webhooks/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "webhooks": { + "hook": { + "description": "description of path item 1" + } + }, + "components": { + "pathItems": { + "pathItem1": { + "description": "description of path item 1" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/webhooks/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/webhooks/root.json new file mode 100644 index 0000000000..569afa66cc --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/__fixtures__/webhooks/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "webhooks": { + "hook": { + "$ref": "#/components/pathItems/pathItem1" + } + }, + "components": { + "pathItems": { + "pathItem1": { + "description": "description of path item 1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/dereference-apidom.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/dereference-apidom.js new file mode 100644 index 0000000000..6d59552dac --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/dereference-apidom.js @@ -0,0 +1,54 @@ +import path from 'node:path'; +import { mediaTypes, isPathItemElement } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate, compile } from '@swagger-api/apidom-json-pointer'; +import { parse, dereferenceApiDOM } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Path Item Object', () => { + describe('given single PathItemElement passed to dereferenceApiDOM', () => { + const fixturePath = path.join(__dirname, '__fixtures__', 'external-only', 'root.json'); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const pathItemElement = evaluate(compile(['paths', '/path1']), parseResult.api); + const dereferenced = await dereferenceApiDOM(pathItemElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(isPathItemElement(dereferenced)).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const pathItemElement = evaluate(compile(['paths', '/path1']), parseResult.api); + const dereferenced = await dereferenceApiDOM(pathItemElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(dereferenced.meta.get('ref-origin').toValue()).toEqual( + expect.stringMatching(/external-only\/ex\.json$/) + ); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/index.js new file mode 100644 index 0000000000..9e59730aaa --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/path-item-object/index.js @@ -0,0 +1,345 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { + dereference, + DereferenceError, + MaximumDereferenceDepthError, +} from '@swagger-api/apidom-reference/configuration/empty'; + +// eslint-disable-next-line camelcase +import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js'; +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Path Item Object', () => { + describe('given in webhooks field', () => { + const fixturePath = path.join(rootFixturePath, 'webhooks'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in components/pathItems field', () => { + const fixturePath = path.join(rootFixturePath, 'components-path-items'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Callback Object', () => { + const fixturePath = path.join(rootFixturePath, 'callback-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Path Item Object $ref field', () => { + describe('given $ref field pointing internally only', () => { + const fixturePath = path.join(rootFixturePath, 'internal-only'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given $ref field pointing externally only', () => { + const fixturePath = path.join(rootFixturePath, 'external-only'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given $ref field pointing internally and externally', () => { + const fixturePath = path.join(rootFixturePath, 'internal-external'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given $ref field + additional fields', () => { + const fixturePath = path.join(rootFixturePath, 'additional-fields'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given external resolution disabled', () => { + const fixturePath = path.join(rootFixturePath, 'ignore-external'); + + test('should not dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { external: false }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given $ref field pointing to internal indirection', () => { + const fixturePath = path.join(rootFixturePath, 'internal-indirections'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given $ref field pointing to external indirections', () => { + const fixturePath = path.join(rootFixturePath, 'external-indirections'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given $ref field pointing internally', () => { + describe('and allowMetaPatches=true', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'meta-patches-internal'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ port: 8123, cwd: fixturePath }); + + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ allowMetaPatches: true }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile( + path.join(fixturePath, 'dereferenced.json') + ); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + + describe('given $ref field pointing externally', () => { + describe('and allowMetaPatches=true', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'meta-patches-external'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ + port: 8123, + cwd: fixturePath, + }); + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ allowMetaPatches: true }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile( + path.join(fixturePath, 'dereferenced.json') + ); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + + describe('given $ref field with invalid JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'invalid-pointer'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given $ref field and maxDepth of dereference', () => { + const fixturePath = path.join(rootFixturePath, 'max-depth'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { maxDepth: 1 }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(MaximumDereferenceDepthError), + }, + }); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + expect.stringMatching(/__fixtures__\/max-depth\/ex1\.json"$/) + ); + }); + }); + + describe('given $ref field with unresolvable JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'unresolvable-path-item'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given $ref field with with direct circular internal reference', () => { + const fixturePath = path.join(rootFixturePath, 'direct-internal-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given $ref field with with indirect circular internal reference', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-internal-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given $ref field with with direct circular external reference', () => { + const fixturePath = path.join(rootFixturePath, 'direct-external-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given $ref field with with indirect circular external reference', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-external-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/dereferenced.json new file mode 100644 index 0000000000..0ef1ca9975 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/dereferenced.json @@ -0,0 +1,39 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "name": "userId", + "in": "query", + "description": "description 1", + "required": true + }, + "indirection1": { + "name": "userId", + "in": "query", + "description": "indirect description 1", + "required": true + }, + "indirection2": { + "name": "userId", + "in": "query", + "description": "indirect description 1", + "required": true + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "pulled from external source", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/root.json new file mode 100644 index 0000000000..eba4e6f9aa --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-fields/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "description 1" + }, + "indirection1": { + "$ref": "#/components/parameters/indirection2", + "summary": "indirect summary 1" + }, + "indirection2": { + "$ref": "#/components/parameters/userIdRef", + "description": "indirect description 1", + "summary": "indirect summary 2" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "pulled from external source" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/dereferenced.json new file mode 100644 index 0000000000..0ef1ca9975 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/dereferenced.json @@ -0,0 +1,39 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "name": "userId", + "in": "query", + "description": "description 1", + "required": true + }, + "indirection1": { + "name": "userId", + "in": "query", + "description": "indirect description 1", + "required": true + }, + "indirection2": { + "name": "userId", + "in": "query", + "description": "indirect description 1", + "required": true + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "pulled from external source", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/root.json new file mode 100644 index 0000000000..87f3dcb727 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/additional-ignored-fields/root.json @@ -0,0 +1,38 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "description 1", + "prop1": "value1", + "prop2": "value2" + }, + "indirection1": { + "$ref": "#/components/parameters/indirection2", + "summary": "indirect summary 1", + "prop1": "value1", + "prop2": "value2" + }, + "indirection2": { + "$ref": "#/components/parameters/userIdRef", + "description": "indirect description 1", + "summary": "indirect summary 2", + "prop1": "value1", + "prop2": "value2" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "pulled from external source", + "prop1": "value1", + "prop2": "value2" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/cycle-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/cycle-internal/root.json new file mode 100644 index 0000000000..badb77703d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/cycle-internal/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "parent": { + "$ref": "#/components/schemas/User" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-external-circular/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-external-circular/ex.json new file mode 100644 index 0000000000..cec551870e --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-external-circular/ex.json @@ -0,0 +1,5 @@ +{ + "externalParameter": { + "$ref": "./root.json#/components/parameters/userId" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-external-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-external-circular/root.json new file mode 100644 index 0000000000..a71015f00b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-external-circular/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "another ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-internal-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-internal-circular/root.json new file mode 100644 index 0000000000..020d39aef6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/direct-internal-circular/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/userId", + "description": "description 1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/dereferenced.json new file mode 100644 index 0000000000..c494edf8b3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/dereferenced.json @@ -0,0 +1,21 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "param2", + "in": "query" + }, + "param2": { + "name": "param2", + "in": "query" + }, + "param3": { + "name": "ex-param3", + "in": "query" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/ex.json new file mode 100644 index 0000000000..2ed2b2f3f2 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/ex.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "$ref": "./root.json#/components/parameters/param2" + }, + "param2": { + "$ref": "./root.json#/components/parameters/param2" + }, + "param3": { + "name": "ex-param3", + "in": "query" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/root.json new file mode 100644 index 0000000000..c95d70defd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-circular-dependency/root.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "$ref": "./ex.json#/components/parameters/param1" + }, + "param2": { + "name": "param2", + "in": "query" + }, + "param3": { + "$ref": "./ex.json#/components/parameters/param3" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/dereferenced.json new file mode 100644 index 0000000000..2e51b197ae --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "external ref", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex2.json new file mode 100644 index 0000000000..091689f702 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/externalParameter" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex3.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/ex3.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/root.json new file mode 100644 index 0000000000..3614c32b3c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-indirections/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/dereferenced.json new file mode 100644 index 0000000000..2e51b197ae --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "external ref", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/root.json new file mode 100644 index 0000000000..ccf0893718 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only-absolute-url/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "http://localhost:8123/ex.json#/externalParameter", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/dereferenced.json new file mode 100644 index 0000000000..2e51b197ae --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "external ref", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/root.json new file mode 100644 index 0000000000..a512c01553 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/external-only/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/dereferenced.json new file mode 100644 index 0000000000..736c0a6798 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/dereferenced.json @@ -0,0 +1,14 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "a": { + "$ref": "#/three" + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/ex.json new file mode 100644 index 0000000000..2e53208cfc --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/ex.json @@ -0,0 +1,15 @@ +{ + "one": { + "$ref": "#/two" + }, + "two": { + "a": { + "$ref": "#/three" + } + }, + "three": { + "b": { + "$ref": "#/two" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/root.json new file mode 100644 index 0000000000..d2127a757b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-arbitrary-$refs/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex.json#/one" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/dereferenced.json new file mode 100644 index 0000000000..995356d521 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/dereferenced.json @@ -0,0 +1,37 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "name": "userId", + "in": "query", + "description": "override", + "required": true + }, + "indirection1": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "indirection2": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "another ref" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/root.json new file mode 100644 index 0000000000..802a6c0b39 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/ignore-external/root.json @@ -0,0 +1,29 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "override" + }, + "indirection1": { + "$ref": "#/components/parameters/indirection2", + "summary": "indirect summary" + }, + "indirection2": { + "$ref": "#/components/parameters/userIdRef", + "summary": "indirect summary" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "another ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex2.json new file mode 100644 index 0000000000..d44c814227 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex3.json new file mode 100644 index 0000000000..92be82752c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/ex3.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./root.json#/components/parameters/externalRef" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/root.json new file mode 100644 index 0000000000..6e1a722371 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-external-circular/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "another ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-internal-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-internal-circular/root.json new file mode 100644 index 0000000000..58cfa384b6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/indirect-internal-circular/root.json @@ -0,0 +1,23 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "description 1" + }, + "indirection1": { + "$ref": "#/components/parameters/indirection2", + "description": "description 1" + }, + "indirection2": { + "$ref": "#/components/parameters/indirection3", + "description": "description 1" + }, + "indirection3": { + "$ref": "#/components/parameters/userId", + "description": "description 1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/dereferenced.json new file mode 100644 index 0000000000..4baa2dc952 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/dereferenced.json @@ -0,0 +1,39 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "name": "userId", + "in": "query", + "description": "override", + "required": true + }, + "indirection1": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "indirection2": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "another ref", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/root.json new file mode 100644 index 0000000000..802a6c0b39 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-external/root.json @@ -0,0 +1,29 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "override" + }, + "indirection1": { + "$ref": "#/components/parameters/indirection2", + "summary": "indirect summary" + }, + "indirection2": { + "$ref": "#/components/parameters/userIdRef", + "summary": "indirect summary" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "another ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-only/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-only/dereferenced.json new file mode 100644 index 0000000000..b50576d2ca --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-only/dereferenced.json @@ -0,0 +1,33 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "name": "userId", + "in": "query", + "description": "override", + "required": true + }, + "indirection1": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "indirection2": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-only/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-only/root.json new file mode 100644 index 0000000000..8f824a35ef --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/internal-only/root.json @@ -0,0 +1,25 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "#/components/parameters/indirection1", + "description": "override" + }, + "indirection1": { + "$ref": "#/components/parameters/indirection2", + "summary": "indirect summary" + }, + "indirection2": { + "$ref": "#/components/parameters/userIdRef", + "summary": "indirect summary" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/invalid-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/invalid-pointer/root.json new file mode 100644 index 0000000000..afde294f76 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/invalid-pointer/root.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "userId": { + "$ref": "invalid-pointer", + "description": "override" + }, + "userIdRef": { + "name": "userId", + "in": "query", + "description": "ID of the user", + "required": true + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex2.json new file mode 100644 index 0000000000..091689f702 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/externalParameter" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex3.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/ex3.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/root.json new file mode 100644 index 0000000000..3614c32b3c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/max-depth/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/dereferenced.json new file mode 100644 index 0000000000..bec19f8a01 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/dereferenced.json @@ -0,0 +1,16 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "external ref", + "required": true, + "$$ref": "http://localhost:8123/ex3.json#/externalParameter" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex2.json new file mode 100644 index 0000000000..091689f702 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/externalParameter" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex3.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/ex3.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/root.json new file mode 100644 index 0000000000..3614c32b3c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-external/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-internal/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-internal/dereferenced.json new file mode 100644 index 0000000000..9dffe470b0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-internal/dereferenced.json @@ -0,0 +1,27 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "name": "offset", + "in": "query", + "required": true, + "$$ref": "http://localhost:8123/root.json#/components/parameters/param3" + }, + "param2": { + "name": "offset", + "in": "query", + "required": true, + "$$ref": "http://localhost:8123/root.json#/components/parameters/param3" + }, + "param3": { + "name": "offset", + "in": "query", + "required": true + } + } + } + } + +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-internal/root.json new file mode 100644 index 0000000000..be9fcab8b0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/meta-patches-internal/root.json @@ -0,0 +1,18 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "param1": { + "$ref": "#/components/parameters/param2" + }, + "param2": { + "$ref": "#/components/parameters/param3" + }, + "param3": { + "name": "offset", + "in": "query", + "required": true + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/dereferenced.json new file mode 100644 index 0000000000..2e51b197ae --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "external ref", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex2.json new file mode 100644 index 0000000000..091689f702 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/externalParameter" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex3.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/ex3.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/root.json new file mode 100644 index 0000000000..3614c32b3c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/path-encoding/path with spaces/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/dereferenced.json new file mode 100644 index 0000000000..2e51b197ae --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "name": "externalParameter", + "in": "query", + "description": "external ref", + "required": true + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex2.json new file mode 100644 index 0000000000..091689f702 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/externalParameter" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex3.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/ex3.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/root.json new file mode 100644 index 0000000000..3614c32b3c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/refset-as-option/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/unresolvable-reference/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/unresolvable-reference/root.json new file mode 100644 index 0000000000..44e42d9fe4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/__fixtures__/unresolvable-reference/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "parameters": { + "externalRef": { + "$ref": "./ex.json#/externalParameter", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/dereference-apidom.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/dereference-apidom.js new file mode 100644 index 0000000000..6685cd37ed --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/dereference-apidom.js @@ -0,0 +1,166 @@ +import path from 'node:path'; +import { mediaTypes, isParameterElement } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { parse, dereferenceApiDOM } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Reference Object', () => { + describe('given single ReferenceElement passed to dereferenceApiDOM', () => { + describe('given dereferencing using local file system', () => { + const fixturePath = path.join(rootFixturePath, 'external-only', 'root.json'); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const referenceElement = evaluate( + '/components/parameters/externalRef', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(isParameterElement(dereferenced)).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const referenceElement = evaluate( + '/components/parameters/externalRef', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(dereferenced.meta.get('ref-origin').toValue()).toEqual( + expect.stringMatching(/external-only\/ex\.json$/) + ); + }); + }); + + describe('given dereferencing using HTTP protocol', () => { + const fixturePath = path.join(rootFixturePath, 'external-only', 'root.json'); + const httpPort = 8123; + let httpServer; + + beforeEach(() => { + const cwd = path.join(rootFixturePath, 'external-only'); + httpServer = globalThis.createHTTPServer({ port: httpPort, cwd }); + }); + + afterEach(async () => { + await httpServer.terminate(); + }); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const referenceElement = evaluate( + '/components/parameters/externalRef', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: `http://localhost:${httpPort}/root.json` }, + }); + + expect(isParameterElement(dereferenced)).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const referenceElement = evaluate( + '/components/parameters/externalRef', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: `http://localhost:${httpPort}/root.json` }, + }); + + expect(dereferenced.meta.get('ref-origin').toValue()).toEqual( + expect.stringMatching(/\/ex\.json$/) + ); + }); + }); + + describe('given dereferencing using HTTP protocol and absolute URLs', () => { + const fixturePath = path.join( + rootFixturePath, + 'external-only-absolute-url', + 'root.json' + ); + const httpPort = 8123; + let httpServer; + + beforeEach(() => { + const cwd = path.join(rootFixturePath, 'external-only-absolute-url'); + httpServer = globalThis.createHTTPServer({ port: httpPort, cwd }); + }); + + afterEach(async () => { + await httpServer.terminate(); + }); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const referenceElement = evaluate( + '/components/parameters/externalRef', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: `http://localhost:${httpPort}/root.json` }, + }); + + expect(isParameterElement(dereferenced)).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const referenceElement = evaluate( + '/components/parameters/externalRef', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: `http://localhost:${httpPort}/root.json` }, + }); + + expect(dereferenced.meta.get('ref-origin').toValue()).toEqual( + expect.stringMatching(/\/ex\.json$/) + ); + }); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/index.js new file mode 100644 index 0000000000..0f06227f85 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/reference-object/index.js @@ -0,0 +1,468 @@ +import path from 'node:path'; +import { ParseResultElement, toValue } from '@swagger-api/apidom-core'; +import { isParameterElement, mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { + dereference, + dereferenceApiDOM, + resolve, + parse, + DereferenceError, + MaximumDereferenceDepthError, + MaximumResolverDepthError, + Reference, + ReferenceSet, +} from '@swagger-api/apidom-reference/configuration/empty'; + +// eslint-disable-next-line camelcase +import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js'; +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Reference Object', () => { + describe('given Reference Objects pointing internally and externally', () => { + const fixturePath = path.join(rootFixturePath, 'internal-external'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should apply semantics to external fragment', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const fragment = evaluate('/0/components/parameters/externalRef', dereferenced); + + expect(isParameterElement(fragment)).toBe(true); + }); + + test('should annotate transcluded element with additional metadata', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const fragment = evaluate('/0/components/parameters/userId', dereferenced); + + expect(fragment.meta.get('ref-fields').get('$ref').toValue()).toStrictEqual( + '#/components/parameters/indirection1' + ); + expect(fragment.meta.get('ref-fields').get('description').toValue()).toStrictEqual( + 'override' + ); + }); + }); + + describe('given Reference Objects pointing internally only', () => { + const fixturePath = path.join(rootFixturePath, 'internal-only'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects pointing externally only', () => { + const fixturePath = path.join(rootFixturePath, 'external-only'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects pointing to external indirections', () => { + const fixturePath = path.join(rootFixturePath, 'external-indirections'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should apply semantics to eventual external fragment', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const fragment = evaluate('/0/components/parameters/externalRef', dereferenced); + + expect(isParameterElement(fragment)).toBe(true); + }); + }); + + describe('given Reference Objects with additional fields', () => { + const fixturePath = path.join(rootFixturePath, 'additional-fields'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects with additional ignored fields', () => { + const fixturePath = path.join(rootFixturePath, 'additional-ignored-fields'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects pointing internally', () => { + describe('and allowMetaPatches=true', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'meta-patches-internal'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ port: 8123, cwd: fixturePath }); + + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ allowMetaPatches: true }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + + describe('given Reference Objects pointing externally', () => { + describe('and allowMetaPatches=true', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'meta-patches-external'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ port: 8123, cwd: fixturePath }); + + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ allowMetaPatches: true }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + + describe('given Reference Objects with internal cycles', () => { + const fixturePath = path.join(rootFixturePath, 'cycle-internal'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const parent = evaluate('/0/components/schemas/User/properties/parent', dereferenced); + const cyclicParent = evaluate( + '/0/components/schemas/User/properties/parent/properties/parent', + dereferenced + ); + + expect(parent).toStrictEqual(cyclicParent); + }); + }); + + describe('given Reference Objects with external resolution disabled', () => { + const fixturePath = path.join(rootFixturePath, 'ignore-external'); + + test('should not dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { external: false }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects with direct circular internal reference', () => { + const fixturePath = path.join(rootFixturePath, 'direct-internal-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Reference Objects with indirect circular internal reference', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-internal-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Reference Objects with direct circular external reference', () => { + const fixturePath = path.join(rootFixturePath, 'direct-external-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Reference Objects with indirect circular external reference', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-external-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Reference Objects with unresolvable reference', () => { + const fixturePath = path.join(rootFixturePath, 'unresolvable-reference'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Reference Objects with invalid JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'invalid-pointer'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Reference Objects with arbitrary circular references', () => { + const fixturePath = path.join(rootFixturePath, 'ignore-arbitrary-$refs'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects with external circular dependency', () => { + const fixturePath = path.join(rootFixturePath, 'external-circular-dependency'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Reference Objects and maxDepth of dereference', () => { + const fixturePath = path.join(rootFixturePath, 'max-depth'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { maxDepth: 2 }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(MaximumDereferenceDepthError), + }, + }); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + expect.stringMatching(/__fixtures__\/max-depth\/ex2\.json"$/) + ); + }); + }); + + describe('given Reference Objects and maxDepth of resolution', () => { + const fixturePath = path.join(rootFixturePath, 'max-depth'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { maxDepth: 2 }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(MaximumResolverDepthError), + }, + }); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + expect.stringMatching(/__fixtures__\/max-depth\/ex2\.json"$/) + ); + }); + }); + + describe('given refSet is provided as an option', () => { + test('should dereference without external resolution', async () => { + const fixturePath = path.join(rootFixturePath, 'refset-as-option'); + const uri = path.join(fixturePath, 'root.json'); + const refSet = await resolve(uri, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const actual = await dereference(uri, { dereference: { refSet } }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should dereference single ApiDOM fragment', async () => { + const fixturePath = path.join(rootFixturePath, 'refset-as-option'); + const uri = path.join(fixturePath, 'root.json'); + const parseResult = await parse(uri, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + // @ts-ignore + const referenceElement = parseResult.api?.components.parameters.get('externalRef'); + const refSet = ReferenceSet(); + const rootFileReference = Reference({ uri, value: parseResult }); + const referenceElementReference = Reference({ + uri: `${uri}#/single-reference-object`, + value: new ParseResultElement([referenceElement]), + }); + // referenceElementReference needs to be added as first to create rootRef + refSet.add(referenceElementReference).add(rootFileReference); + + const actual = await dereferenceApiDOM(referenceElement, { + parse: { mediaType: mediaTypes.latest('generic') }, + resolve: { baseURI: uri }, + dereference: { refSet }, + }); + + const expected = { + name: 'externalParameter', + in: 'query', + description: 'external ref', + required: true, + }; + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given path with invalid URL characters - spaces', () => { + const fixturePath = path.join(rootFixturePath, 'path-encoding', 'path with spaces'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/components-request-bodies/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/components-request-bodies/dereferenced.json new file mode 100644 index 0000000000..6ad8f1d23b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/components-request-bodies/dereferenced.json @@ -0,0 +1,15 @@ +[ + { + "openapi": "3.1.0", + "components": { + "requestBodies": { + "requestBody1": { + "description": "example1 description" + }, + "requestBody2": { + "description": "example1 description" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/components-request-bodies/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/components-request-bodies/root.json new file mode 100644 index 0000000000..5ec8a98824 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/components-request-bodies/root.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.1.0", + "components": { + "requestBodies": { + "requestBody1": { + "description": "example1 description" + }, + "requestBody2": { + "$ref": "#/components/requestBodies/requestBody1" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/operation-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/operation-object/dereferenced.json new file mode 100644 index 0000000000..8c50937f46 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/operation-object/dereferenced.json @@ -0,0 +1,21 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "requestBody": { + "description": "description of request body 2" + } + } + } + }, + "components": { + "requestBodies": { + "requestBody2": { + "description": "description of request body 2" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/operation-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/operation-object/root.json new file mode 100644 index 0000000000..5cb414e333 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/__fixtures__/operation-object/root.json @@ -0,0 +1,19 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "requestBody": { + "$ref": "#/components/requestBodies/requestBody2" + } + } + } + }, + "components": { + "requestBodies": { + "requestBody2": { + "description": "description of request body 2" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/index.js new file mode 100644 index 0000000000..81077270f5 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/request-body-object/index.js @@ -0,0 +1,52 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Request Body Object', () => { + describe('given in components/requestBodies field', () => { + const fixturePath = path.join(rootFixturePath, 'components-request-bodies'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Operation Object', () => { + const fixturePath = path.join(rootFixturePath, 'operation-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/components-responses/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/components-responses/dereferenced.json new file mode 100644 index 0000000000..990f84fd2c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/components-responses/dereferenced.json @@ -0,0 +1,31 @@ +[ + { + "openapi": "3.1.0", + "components": { + "responses": { + "201": { + "description": "201 description", + "headers": { + "Content-Type": { + "description": "The number of allowed requests in the current period", + "schema": { + "type": "integer" + } + } + } + }, + "400": { + "description": "201 description", + "headers": { + "Content-Type": { + "description": "The number of allowed requests in the current period", + "schema": { + "type": "integer" + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/components-responses/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/components-responses/root.json new file mode 100644 index 0000000000..9b8fa923a3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/components-responses/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "responses": { + "201": { + "description": "201 description", + "headers": { + "Content-Type": { + "description": "The number of allowed requests in the current period", + "schema": { + "type": "integer" + } + } + } + }, + "400": { + "$ref": "#/components/responses/201" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/responses-object/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/responses-object/dereferenced.json new file mode 100644 index 0000000000..8100dbd632 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/responses-object/dereferenced.json @@ -0,0 +1,29 @@ +[ + { + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "responses": { + "default": { + "description": "first response object" + }, + "200": { + "description": "second response object" + } + } + } + } + }, + "components": { + "responses": { + "default": { + "description": "first response object" + }, + "200": { + "description": "second response object" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/responses-object/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/responses-object/root.json new file mode 100644 index 0000000000..b16f8bfce3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/__fixtures__/responses-object/root.json @@ -0,0 +1,27 @@ +{ + "openapi": "3.1.0", + "paths": { + "/path": { + "get": { + "responses": { + "default": { + "$ref": "#/components/responses/default" + }, + "200": { + "$ref": "#/components/responses/200" + } + } + } + } + }, + "components": { + "responses": { + "default": { + "description": "first response object" + }, + "200": { + "description": "second response object" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/index.js new file mode 100644 index 0000000000..99c0ae257b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/response-object/index.js @@ -0,0 +1,52 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Response Object', () => { + describe('given in components/responses field', () => { + const fixturePath = path.join(rootFixturePath, 'components-responses'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given in Responses Object', () => { + const fixturePath = path.join(rootFixturePath, 'responses-object'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/dereferenced.json new file mode 100644 index 0000000000..2fd205625d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/dereferenced.json @@ -0,0 +1,31 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$anchor": "user-profile", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/ex.json new file mode 100644 index 0000000000..b32830bdc4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/ex.json @@ -0,0 +1,15 @@ +{ + "$defs": { + "UserProfile": { + "$anchor": "user-profile", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/root.json new file mode 100644 index 0000000000..5f55276688 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-external/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "./ex.json#user-profile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-internal/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-internal/dereferenced.json new file mode 100644 index 0000000000..6c8fd1b7b6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-internal/dereferenced.json @@ -0,0 +1,42 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$anchor": "user-profile", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "$anchor": "user-profile", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-internal/root.json new file mode 100644 index 0000000000..f9a30fb1ca --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-internal/root.json @@ -0,0 +1,32 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#user-profile" + } + } + }, + "UserProfile": { + "$anchor": "user-profile", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-not-found/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-not-found/root.json new file mode 100644 index 0000000000..f0f2dce912 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$anchor-not-found/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#user-profile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-unresolvable/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-unresolvable/root.json new file mode 100644 index 0000000000..a8a8381127 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-unresolvable/root.json @@ -0,0 +1,23 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$id": "./schemas/", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$id": "./nested/", + "$ref": "./ex.json" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/dereferenced.json new file mode 100644 index 0000000000..8ffbd8fe73 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/dereferenced.json @@ -0,0 +1,29 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$id": "./nested/", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/nested/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/nested/ex.json new file mode 100644 index 0000000000..b7f7f6299c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/nested/ex.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/root.json new file mode 100644 index 0000000000..2c9fd869f7 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-direct/root.json @@ -0,0 +1,22 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$id": "./nested/", + "$ref": "./ex.json" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/dereferenced.json new file mode 100644 index 0000000000..52f96bfc49 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/dereferenced.json @@ -0,0 +1,29 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$id": "./nested/", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/nested/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/nested/ex.json new file mode 100644 index 0000000000..b7f7f6299c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/nested/ex.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/root.json new file mode 100644 index 0000000000..4c3fa339ca --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-enclosing/root.json @@ -0,0 +1,22 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$id": "./nested/", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "./ex.json" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/dereferenced.json new file mode 100644 index 0000000000..8ffbd8fe73 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/dereferenced.json @@ -0,0 +1,29 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$id": "./nested/", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/nested/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/nested/ex.json new file mode 100644 index 0000000000..d5a6ae02c1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/nested/ex.json @@ -0,0 +1,8 @@ +{ + "$defs": { + "UserProfile": { + "$id": "./nested/", + "$ref": "./ex.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/nested/nested/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/nested/nested/ex.json new file mode 100644 index 0000000000..b7f7f6299c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/nested/nested/ex.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/root.json new file mode 100644 index 0000000000..ede427d60e --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$id-uri-external/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "./nested/ex.json#/$defs/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-$anchor/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-$anchor/dereferenced.json new file mode 100644 index 0000000000..bdca4c2d4b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-$anchor/dereferenced.json @@ -0,0 +1,34 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$anchor": "avatar", + "type": "string" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "$anchor": "avatar", + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-$anchor/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-$anchor/root.json new file mode 100644 index 0000000000..ab1df7012d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-$anchor/root.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "https://swagger.io/schemas/user-profile#avatar" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "$anchor": "avatar", + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-pointer/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-pointer/dereferenced.json new file mode 100644 index 0000000000..e21296c93f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-pointer/dereferenced.json @@ -0,0 +1,32 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "string" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-pointer/root.json new file mode 100644 index 0000000000..89e31d3af1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-pointer/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "https://swagger.io/schemas/user-profile#/properties/avatar" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-relative-reference/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-relative-reference/dereferenced.json new file mode 100644 index 0000000000..5e1ef488f1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-relative-reference/dereferenced.json @@ -0,0 +1,35 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "$id": "https://swagger.io/schemas/user", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profileAvatar": { + "$id": "/schemas/user-profile/avatar", + "type": "string" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "$id": "/schemas/user-profile/avatar", + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-relative-reference/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-relative-reference/root.json new file mode 100644 index 0000000000..80a5976a86 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-relative-reference/root.json @@ -0,0 +1,32 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "$id": "https://swagger.io/schemas/user", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profileAvatar": { + "$ref": "/schemas/user-profile/avatar" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "$id": "/schemas/user-profile/avatar", + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/dereferenced.json new file mode 100644 index 0000000000..d79569c33d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/dereferenced.json @@ -0,0 +1,23 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/ex.json new file mode 100644 index 0000000000..b7f7f6299c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/ex.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/root.json new file mode 100644 index 0000000000..7e6dec92a2 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-resolvable/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "./ex.json#/properties/avatar" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-unresolvable/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-unresolvable/root.json new file mode 100644 index 0000000000..37f1a25cc3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url-unresolvable/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "./ex.json" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url/dereferenced.json new file mode 100644 index 0000000000..990e6b83a1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url/dereferenced.json @@ -0,0 +1,38 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url/root.json new file mode 100644 index 0000000000..1b6485de39 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-url/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "https://swagger.io/schemas/user-profile" + } + } + }, + "UserProfile": { + "$id": "https://swagger.io/schemas/user-profile", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-$anchor/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-$anchor/dereferenced.json new file mode 100644 index 0000000000..ded6680a23 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-$anchor/dereferenced.json @@ -0,0 +1,34 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$anchor": "avatar", + "type": "string" + } + } + }, + "UserProfile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "$anchor": "avatar", + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-$anchor/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-$anchor/root.json new file mode 100644 index 0000000000..c519c4e62d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-$anchor/root.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#avatar" + } + } + }, + "UserProfile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "$anchor": "avatar", + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-pointer/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-pointer/dereferenced.json new file mode 100644 index 0000000000..eb6bf72bfe --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-pointer/dereferenced.json @@ -0,0 +1,32 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "string" + } + } + }, + "UserProfile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-pointer/root.json new file mode 100644 index 0000000000..c53665d5a4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-pointer/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#/properties/avatar" + } + } + }, + "UserProfile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-unresolvable/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-unresolvable/root.json new file mode 100644 index 0000000000..f508f83e24 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn-unresolvable/root.json @@ -0,0 +1,21 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "urn:uuid:3" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn/dereferenced.json new file mode 100644 index 0000000000..61fb93c201 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn/dereferenced.json @@ -0,0 +1,38 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn/root.json new file mode 100644 index 0000000000..2c3a9eabd4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$ref-urn/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" + } + } + }, + "UserProfile": { + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-defined/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-defined/dereferenced.json new file mode 100644 index 0000000000..f9bf74b20c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-defined/dereferenced.json @@ -0,0 +1,39 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-defined/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-defined/root.json new file mode 100644 index 0000000000..34af5e8ce4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-defined/root.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-enclosing/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-enclosing/dereferenced.json new file mode 100644 index 0000000000..aaba585ba1 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-enclosing/dereferenced.json @@ -0,0 +1,37 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-enclosing/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-enclosing/root.json new file mode 100644 index 0000000000..2d4f976f0a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-enclosing/root.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-mixed/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-mixed/dereferenced.json new file mode 100644 index 0000000000..c422a7ef68 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-mixed/dereferenced.json @@ -0,0 +1,39 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-mixed/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-mixed/root.json new file mode 100644 index 0000000000..dd3b4c451b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-mixed/root.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "$schema": "https://spec.openapis.org/oas/3.1/dialect/base", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-undefined/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-undefined/dereferenced.json new file mode 100644 index 0000000000..8070ecde7a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-undefined/dereferenced.json @@ -0,0 +1,36 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-undefined/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-undefined/root.json new file mode 100644 index 0000000000..0360dcac66 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-undefined/root.json @@ -0,0 +1,29 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-unrecognized/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-unrecognized/dereferenced.json new file mode 100644 index 0000000000..a721e07f86 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-unrecognized/dereferenced.json @@ -0,0 +1,39 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://www.google.com/", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$schema": "https://www.google.com/", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "$schema": "https://www.google.com/", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-unrecognized/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-unrecognized/root.json new file mode 100644 index 0000000000..2eb3753431 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/$schema-unrecognized/root.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$schema": "https://www.google.com/", + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "$schema": "https://www.google.com/", + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/boolean-json-schema/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/boolean-json-schema/dereferenced.json new file mode 100644 index 0000000000..848bdd22fc --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/boolean-json-schema/dereferenced.json @@ -0,0 +1,22 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": true + } + }, + "UserProfile": true + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/boolean-json-schema/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/boolean-json-schema/root.json new file mode 100644 index 0000000000..2e4b6a1feb --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/boolean-json-schema/root.json @@ -0,0 +1,22 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": true + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/dereferenced.json new file mode 100644 index 0000000000..325bce9102 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/dereferenced.json @@ -0,0 +1,21 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "properties": { + "parent": { + "$ref": "http://localhost:8123/ex.json#/$defs/UserProfile" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/ex.json new file mode 100644 index 0000000000..3867c3eeb0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/ex.json @@ -0,0 +1,11 @@ +{ + "$defs": { + "UserProfile": { + "properties": { + "parent": { + "$ref": "#/$defs/UserProfile" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/root.json new file mode 100644 index 0000000000..15ee3edf1c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled-http/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "$ref": "./ex.json#/$defs/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/dereferenced.json new file mode 100644 index 0000000000..f11c4f3b9c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/dereferenced.json @@ -0,0 +1,21 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "properties": { + "parent": { + "$ref": "/home/smartbear/ex.json#/$defs/UserProfile" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/ex.json new file mode 100644 index 0000000000..3867c3eeb0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/ex.json @@ -0,0 +1,11 @@ +{ + "$defs": { + "UserProfile": { + "properties": { + "parent": { + "$ref": "#/$defs/UserProfile" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/root.json new file mode 100644 index 0000000000..15ee3edf1c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external-disabled/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "$ref": "./ex.json#/$defs/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external/ex.json new file mode 100644 index 0000000000..3867c3eeb0 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external/ex.json @@ -0,0 +1,11 @@ +{ + "$defs": { + "UserProfile": { + "properties": { + "parent": { + "$ref": "#/$defs/UserProfile" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external/root.json new file mode 100644 index 0000000000..15ee3edf1c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-external/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "$ref": "./ex.json#/$defs/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled-http/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled-http/dereferenced.json new file mode 100644 index 0000000000..9f25cf0878 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled-http/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "parent": { + "$ref": "http://localhost:8123/root.json#/components/schemas/User" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled-http/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled-http/root.json new file mode 100644 index 0000000000..badb77703d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled-http/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "parent": { + "$ref": "#/components/schemas/User" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled/dereferenced.json new file mode 100644 index 0000000000..02e2d9e1a5 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "parent": { + "$ref": "/home/smartbear/root.json#/components/schemas/User" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled/root.json new file mode 100644 index 0000000000..badb77703d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-disabled/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "parent": { + "$ref": "#/components/schemas/User" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-external/ex.json new file mode 100644 index 0000000000..9251c7a6f9 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-external/ex.json @@ -0,0 +1,11 @@ +{ + "$defs": { + "UserProfile": { + "properties": { + "user": { + "$ref": "./root.json#/components/schemas/User" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-external/root.json new file mode 100644 index 0000000000..00f24682e8 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal-external/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "x-track": "1", + "properties": { + "profile": { + "$ref": "./ex.json#/$defs/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal/root.json new file mode 100644 index 0000000000..badb77703d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/cycle-internal/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "parent": { + "$ref": "#/components/schemas/User" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-external-circular/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-external-circular/ex.json new file mode 100644 index 0000000000..33dfbc1e5d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-external-circular/ex.json @@ -0,0 +1,7 @@ +{ + "$defs": { + "User": { + "$ref": "./root.json#/components/schemas/User" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-external-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-external-circular/root.json new file mode 100644 index 0000000000..a5138ec7bc --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-external-circular/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$ref": "./ex.json#/$defs/User" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-internal-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-internal-circular/root.json new file mode 100644 index 0000000000..fedad74def --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/direct-internal-circular/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$ref": "#/components/schemas/User" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/dereferenced.json new file mode 100644 index 0000000000..b7064c600c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/dereferenced.json @@ -0,0 +1,38 @@ +[ + { + "info": { + "title": "Swagger Petstore", + "version": "1.0.0" + }, + "openapi": "3.1.0", + "paths": { + "/pets": { + "get": { + "operationId": "listPets", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "number" + } + }, + "application/yaml": { + "schema": { + "$anchor": "Pet", + "type": "number" + } + } + } + } + } + } + } + }, + "servers": [ + { + "url": "http://petstore.swagger.io/v1" + } + ] + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def.yml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def.yml new file mode 100644 index 0000000000..3191624521 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def.yml @@ -0,0 +1,4 @@ +components: + schemas: + Pet: + $ref: "./def2.yml#/components/schemas/Pet" diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def2.yml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def2.yml new file mode 100644 index 0000000000..aa2244e3cf --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def2.yml @@ -0,0 +1,4 @@ +components: + schemas: + Pet: + type: number diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def3.yml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def3.yml new file mode 100644 index 0000000000..19c9ed597f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/def3.yml @@ -0,0 +1,4 @@ +$defs: + Pet: + $anchor: Pet + type: number diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/pets.yml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/pets.yml new file mode 100644 index 0000000000..bf25452e7a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/pets.yml @@ -0,0 +1,5 @@ +get: + operationId: listPets + responses: + "200": + $ref: "./response.yml" diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/response.yml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/response.yml new file mode 100644 index 0000000000..35c495a154 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/pets/response.yml @@ -0,0 +1,7 @@ +content: + application/json: + schema: + $ref: "./def.yml#/components/schemas/Pet" + application/yaml: + schema: + $ref: "./def3.yml#Pet" diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/root.yml b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/root.yml new file mode 100644 index 0000000000..9b879ef29d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/document-boundaries/root.yml @@ -0,0 +1,10 @@ +openapi: "3.1.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + $ref: "./pets/pets.yml" + diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/dereferenced.json new file mode 100644 index 0000000000..a3a4d8956a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/dereferenced.json @@ -0,0 +1,18 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "schema1": { + "type": "object" + }, + "schema2": { + "type": "object" + }, + "schema3": { + "type": "string" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/ex.json new file mode 100644 index 0000000000..088123c177 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/ex.json @@ -0,0 +1,13 @@ +{ + "$defs": { + "schema1": { + "$ref": "./root.json#/components/schemas/schema2" + }, + "schema2": { + "$ref": "./root.json#/components/schemas/schema2" + }, + "schema3": { + "type": "string" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/root.json new file mode 100644 index 0000000000..cb923170f5 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-circular-dependency/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "schema1": { + "$ref": "./ex.json#/$defs/schema1" + }, + "schema2": { + "type": "object" + }, + "schema3": { + "$ref": "./ex.json#/$defs/schema3" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/dereferenced.json new file mode 100644 index 0000000000..fefdfe26ab --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/dereferenced.json @@ -0,0 +1,17 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "Indirection": { + "type": "object", + "properties": { + "prop1": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex1.json new file mode 100644 index 0000000000..b36a740b4a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex1.json @@ -0,0 +1,7 @@ +{ + "$defs": { + "Indirection": { + "$ref": "./ex2.json#/$defs/Indirection" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex2.json new file mode 100644 index 0000000000..fde1576500 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex2.json @@ -0,0 +1,7 @@ +{ + "$defs": { + "Indirection": { + "$ref": "./ex3.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex3.json new file mode 100644 index 0000000000..c27dc30383 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/ex3.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "properties": { + "prop1": { + "type": "string" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/root.json new file mode 100644 index 0000000000..c4b862d724 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-indirections/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "Indirection": { + "$ref": "./ex1.json#/$defs/Indirection" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/dereferenced.json new file mode 100644 index 0000000000..85fde7c64f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/dereferenced.json @@ -0,0 +1,25 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/ex.json new file mode 100644 index 0000000000..c115310b05 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/ex.json @@ -0,0 +1,16 @@ +{ + "type": "object", + "$defs": { + "UserProfile": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/root.json new file mode 100644 index 0000000000..15ee3edf1c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/external-only/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "$ref": "./ex.json#/$defs/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/dereferenced.json new file mode 100644 index 0000000000..45494ad27c --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/dereferenced.json @@ -0,0 +1,33 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + }, + "Order": { + "$ref": "./ex.json" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/ex.json new file mode 100644 index 0000000000..fc8a07edcd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/ex.json @@ -0,0 +1,8 @@ +{ + "externalParameter": { + "name": "externalParameter", + "in": "query", + "description": "this is parameter stored in external file", + "required": true + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/root.json new file mode 100644 index 0000000000..b58b884fd6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/ignore-external/root.json @@ -0,0 +1,26 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + }, + "Order": { + "$ref": "./ex.json" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex1.json new file mode 100644 index 0000000000..cb58d6153f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex1.json @@ -0,0 +1,7 @@ +{ + "$defs": { + "User": { + "$ref": "./ex2.json#/$defs/User" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex2.json new file mode 100644 index 0000000000..556373d11d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex2.json @@ -0,0 +1,7 @@ +{ + "$defs": { + "User": { + "$ref": "./ex3.json#/$defs/User" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex3.json new file mode 100644 index 0000000000..33dfbc1e5d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/ex3.json @@ -0,0 +1,7 @@ +{ + "$defs": { + "User": { + "$ref": "./root.json#/components/schemas/User" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/root.json new file mode 100644 index 0000000000..041b79aa73 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-external-circular/root.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$ref": "./ex1.json#/$defs/User" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal-circular/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal-circular/root.json new file mode 100644 index 0000000000..460612050d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal-circular/root.json @@ -0,0 +1,19 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$ref": "#/components/schemas/Indirection1" + }, + "Indirection1": { + "$ref": "#/components/schemas/Indirection2" + }, + "Indirection3": { + "$ref": "#/components/schemas/Indirection3" + }, + "Indirection4": { + "$ref": "#/components/schemas/User" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal/dereferenced.json new file mode 100644 index 0000000000..7e1ddf05f8 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal/dereferenced.json @@ -0,0 +1,18 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object" + }, + "Indirection1": { + "type": "object" + }, + "Indirection2": { + "type": "object" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal/root.json new file mode 100644 index 0000000000..ed545e988d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/indirect-internal/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "$ref": "#/components/schemas/Indirection1" + }, + "Indirection1": { + "$ref": "#/components/schemas/Indirection2" + }, + "Indirection2": { + "type": "object" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/infinite-recursion/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/infinite-recursion/root.json new file mode 100644 index 0000000000..145ae4496d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/infinite-recursion/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "$ref": "#/components/schemas/UserProfile" + }, + "UserProfile": { + "type": "object", + "$ref": "#/components/schemas/User" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/dereferenced.json new file mode 100644 index 0000000000..149231aee5 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/dereferenced.json @@ -0,0 +1,44 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Order": { + "type": "object", + "properties": { + "orderId": { + "type": "number" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/ex.json new file mode 100644 index 0000000000..8386ec5706 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/ex.json @@ -0,0 +1,12 @@ +{ + "$defs": { + "Order": { + "type": "object", + "properties": { + "orderId": { + "type": "number" + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/root.json new file mode 100644 index 0000000000..24c9fa2471 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-external/root.json @@ -0,0 +1,29 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Order": { + "$ref": "./ex.json#/$defs/Order" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-only/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-only/dereferenced.json new file mode 100644 index 0000000000..8070ecde7a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-only/dereferenced.json @@ -0,0 +1,36 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-only/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-only/root.json new file mode 100644 index 0000000000..0360dcac66 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/internal-only/root.json @@ -0,0 +1,29 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "password": { + "type": "string" + }, + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/invalid-pointer/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/invalid-pointer/root.json new file mode 100644 index 0000000000..4a8c563523 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/invalid-pointer/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "$ref": "#/components/schemas/invalid-pointer" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex1.json new file mode 100644 index 0000000000..7de8b6d855 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex1.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "$defs": { + "Indirection": { + "$ref": "./ex2.json#/$defs/Indirection" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex2.json new file mode 100644 index 0000000000..39ed0289dd --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex2.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "$defs": { + "Indirection": { + "$ref": "./ex3.json" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex3.json new file mode 100644 index 0000000000..e6307dc1c6 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/ex3.json @@ -0,0 +1,3 @@ +{ + "type": "object" +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/root.json new file mode 100644 index 0000000000..c20c6b510d --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/max-depth/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "$ref": "./ex1.json#/$defs/Indirection" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/dereferenced.json new file mode 100644 index 0000000000..d0dd4b205a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/dereferenced.json @@ -0,0 +1,44 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "description": "user profile", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + }, + "UserProfile": { + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Order": { + "type": "object", + "properties": { + "orderId": { + "type": "number" + } + } + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/ex.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/ex.json new file mode 100644 index 0000000000..bcdbb69541 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/ex.json @@ -0,0 +1,8 @@ +{ + "type": "object", + "properties": { + "orderId": { + "type": "number" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/root.json new file mode 100644 index 0000000000..63ac9e5bd2 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/merging-keywords/root.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "description": "user profile", + "$ref": "#/components/schemas/UserProfile" + } + } + }, + "UserProfile": { + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Order": { + "type": "object", + "$ref": "./ex.json" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/dereferenced.json new file mode 100644 index 0000000000..4d409494c4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/dereferenced.json @@ -0,0 +1,14 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "externalRef": { + "description": "external ref", + "type": "object", + "$$ref": "http://localhost:8123/ex3.json#/$defs/externalSchema" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex1.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex1.json new file mode 100644 index 0000000000..f46bebc5f4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex1.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex2.json#/indirection" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex2.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex2.json new file mode 100644 index 0000000000..ceeb4f9251 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex2.json @@ -0,0 +1,5 @@ +{ + "indirection": { + "$ref": "./ex3.json#/$defs/externalSchema" + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex3.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex3.json new file mode 100644 index 0000000000..e0e2ec2e5f --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/ex3.json @@ -0,0 +1,8 @@ +{ + "$defs": { + "externalSchema": { + "description": "this is path item stored in external file", + "type": "object" + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/root.json new file mode 100644 index 0000000000..fe6be223aa --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-external/root.json @@ -0,0 +1,11 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "externalRef": { + "$ref": "./ex1.json#/indirection", + "description": "external ref" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-internal/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-internal/dereferenced.json new file mode 100644 index 0000000000..6f9ffbff9a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-internal/dereferenced.json @@ -0,0 +1,20 @@ +[ + { + "openapi": "3.1.0", + "components": { + "schemas": { + "schema1": { + "type": "object", + "$$ref": "http://localhost:8123/root.json#/components/schemas/schema3" + }, + "schema2": { + "type": "object", + "$$ref": "http://localhost:8123/root.json#/components/schemas/schema3" + }, + "schema3": { + "type": "object" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-internal/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-internal/root.json new file mode 100644 index 0000000000..3b107b785b --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/meta-patches-internal/root.json @@ -0,0 +1,16 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "schema1": { + "$ref": "#/components/schemas/schema2" + }, + "schema2": { + "$ref": "#/components/schemas/schema3" + }, + "schema3": { + "type": "object" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/unresolvable-reference/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/unresolvable-reference/root.json new file mode 100644 index 0000000000..6269b86390 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/__fixtures__/unresolvable-reference/root.json @@ -0,0 +1,14 @@ +{ + "openapi": "3.1.0", + "components": { + "schemas": { + "User": { + "properties": { + "profile": { + "$ref": "#/components/schemas/UserProfile" + } + } + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/dereference-apidom.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/dereference-apidom.js new file mode 100644 index 0000000000..eef9e3e9e8 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/dereference-apidom.js @@ -0,0 +1,60 @@ +import path from 'node:path'; +import { mediaTypes, isSchemaElement } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { parse, dereferenceApiDOM } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Schema Object', () => { + describe('given single SchemaElement passed to dereferenceApiDOM', () => { + const fixturePath = path.join(__dirname, '__fixtures__', 'external-only', 'root.json'); + + test('should dereference', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const schemaElement = evaluate( + '/components/schemas/User/properties/profile', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(schemaElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(isSchemaElement(dereferenced)).toBe(true); + }); + + test('should dereference and contain metadata about origin', async () => { + const parseResult = await parse(fixturePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const pathItemElement = evaluate( + '/components/schemas/User/properties/profile', + parseResult.api + ); + const dereferenced = await dereferenceApiDOM(pathItemElement, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { baseURI: fixturePath }, + }); + + expect(dereferenced.meta.get('ref-origin').toValue()).toEqual( + expect.stringMatching(/external-only\/ex\.json$/) + ); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/index.js new file mode 100644 index 0000000000..9f51b3677a --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/schema-object/index.js @@ -0,0 +1,969 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { isSchemaElement, mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { evaluate } from '@swagger-api/apidom-json-pointer'; +import { + DereferenceError, + MaximumDereferenceDepthError, + MaximumResolverDepthError, + ResolverError, + dereference, + resolve, +} from '@swagger-api/apidom-reference/configuration/empty'; +import { EvaluationJsonSchema$anchorError } from '@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/$anchor'; +import { EvaluationJsonSchemaUriError } from '@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/uri'; + +// eslint-disable-next-line camelcase +import OpenApi3_1SwaggerClientDereferenceStrategy from '../../../../../../../../src/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js'; +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Schema Object - $ref keyword from core vocabulary', () => { + describe('given Schema Objects pointing internally and externally', () => { + const fixturePath = path.join(rootFixturePath, 'internal-external'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should apply semantics to external fragment', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const fragment = evaluate('/0/components/schemas/Order', dereferenced); + + expect(isSchemaElement(fragment)).toBe(true); + }); + + test('should annotate transcluded element with additional metadata', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const fragment = evaluate( + '/0/components/schemas/User/properties/profile', + dereferenced + ); + + expect(fragment.meta.get('ref-fields').get('$ref').toValue()).toStrictEqual( + '#/components/schemas/UserProfile' + ); + }); + }); + + describe('given Schema Objects pointing internally only', () => { + const fixturePath = path.join(rootFixturePath, 'internal-only'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects pointing to internal indirections', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-internal'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with internal cycles', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'cycle-internal'); + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const parent = evaluate('/0/components/schemas/User/properties/parent', dereferenced); + const cyclicParent = evaluate( + '/0/components/schemas/User/properties/parent/properties/parent', + dereferenced + ); + + expect(parent).toStrictEqual(cyclicParent); + }); + + describe('and useCircularStructures=false', () => { + test('should avoid cycles by skipping transclusion', async () => { + const fixturePath = path.join(rootFixturePath, 'cycle-internal-disabled'); + const rootFilePath = path.join(fixturePath, 'root.json'); + const refSet = await resolve(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + refSet.refs[0].uri = '/home/smartbear/root.json'; + const actual = await dereference('/home/smartbear/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + refSet, + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ useCircularStructures: false }), + ], + }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + describe('and using HTTP protocol', () => { + test('should make JSON Pointer absolute', async () => { + const fixturePath = path.join(rootFixturePath, 'cycle-external-disabled-http'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ port: 8123, cwd: fixturePath }); + + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ + useCircularStructures: false, + }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile( + path.join(fixturePath, 'dereferenced.json') + ); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + }); + + describe('given Schema Objects with external cycles', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'cycle-external'); + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const parent = evaluate( + '/0/components/schemas/User/properties/profile/properties/parent', + dereferenced + ); + const cyclicParent = evaluate( + '/0/components/schemas/User/properties/profile/properties/parent/properties/parent', + dereferenced + ); + + expect(parent).toStrictEqual(cyclicParent); + }); + + describe('and useCircularStructures=false', () => { + test('should avoid cycles by skipping transclusion', async () => { + const fixturePath = path.join(rootFixturePath, 'cycle-external-disabled'); + const rootFilePath = path.join(fixturePath, 'root.json'); + const refSet = await resolve(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + refSet.refs[0].uri = '/home/smartbear/root.json'; + refSet.refs[1].uri = '/home/smartbear/ex.json'; + const actual = await dereference('/home/smartbear/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + refSet, + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ useCircularStructures: false }), + ], + }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + + describe('given Schema Object pointing internally', () => { + describe('and allowMetaPatches=true', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'meta-patches-internal'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ port: 8123, cwd: fixturePath }); + + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ allowMetaPatches: true }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + + describe('given Schema Object pointing externally', () => { + describe('and allowMetaPatches=true', () => { + test('should dereference', async () => { + const fixturePath = path.join(rootFixturePath, 'meta-patches-external'); + const dereferenceThunk = async () => { + const httpServer = globalThis.createHTTPServer({ port: 8123, cwd: fixturePath }); + + try { + return toValue( + await dereference('http://localhost:8123/root.json', { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ allowMetaPatches: true }), + ], + }, + }) + ); + } finally { + await httpServer.terminate(); + } + }; + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + await expect(dereferenceThunk()).resolves.toEqual(expected); + }); + }); + }); + + describe('given Schema Objects with internal and external cycles', () => { + const fixturePath = path.join(rootFixturePath, 'cycle-internal-external'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const user = evaluate( + '/0/components/schemas/User/properties/profile/properties/user', + dereferenced + ); + const cyclicUserInProfile = evaluate( + '/0/components/schemas/User/properties/profile/properties/user/properties/profile/properties/user', + dereferenced + ); + + expect(user).toStrictEqual(cyclicUserInProfile); + }); + }); + + describe('given Schema Objects with external circular dependency', () => { + const fixturePath = path.join(rootFixturePath, 'external-circular-dependency'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with external resolution disabled', () => { + const fixturePath = path.join(rootFixturePath, 'ignore-external'); + + test('should not dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { external: false }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with overlapping keywords', () => { + const fixturePath = path.join(rootFixturePath, 'merging-keywords'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects pointing externally only', () => { + const fixturePath = path.join(rootFixturePath, 'external-only'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects pointing to external indirections', () => { + const fixturePath = path.join(rootFixturePath, 'external-indirections'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + + test('should apply semantics to eventual external fragment', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const fragment = evaluate('/0/components/schemas/Indirection', dereferenced); + + expect(isSchemaElement(fragment)).toBe(true); + }); + }); + + describe('given Schema Objects with $schema keyword defined', () => { + const fixturePath = path.join(rootFixturePath, '$schema-defined'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $schema keyword defined in enclosing Schema Object', () => { + let dereferenced; + let expected; + + beforeEach(async () => { + const fixturePath = path.join(rootFixturePath, '$schema-enclosing'); + const rootFilePath = path.join(fixturePath, 'root.json'); + dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + }); + + test('should dereference', async () => { + expect(toValue(dereferenced)).toEqual(expected); + }); + + test('should retain $schema before dereferencing', () => { + const profile = evaluate('/0/components/schemas/User/properties/profile', dereferenced); + + expect(profile.meta.get('inherited$schema').toValue()).toStrictEqual( + 'https://spec.openapis.org/oas/3.1/dialect/base' + ); + }); + }); + + describe('given Schema Objects with mixed $schema keyword defined', () => { + const fixturePath = path.join(rootFixturePath, '$schema-mixed'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with undefined $schema keyword', () => { + let dereferenced; + let expected; + + beforeEach(async () => { + const fixturePath = path.join(rootFixturePath, '$schema-undefined'); + const rootFilePath = path.join(fixturePath, 'root.json'); + dereferenced = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + }); + + test('should dereference', async () => { + expect(toValue(dereferenced)).toEqual(expected); + }); + + test('should inherit default $schema dialect for User', () => { + const user = evaluate('/0/components/schemas/User', dereferenced); + + expect(user.meta.get('inherited$schema').toValue()).toStrictEqual( + 'https://spec.openapis.org/oas/3.1/dialect/base' + ); + }); + + test('should inherit default $schema dialect for User.login', () => { + const user = evaluate('/0/components/schemas/User/properties/login', dereferenced); + + expect(user.meta.get('inherited$schema').toValue()).toStrictEqual( + 'https://spec.openapis.org/oas/3.1/dialect/base' + ); + }); + + test('should inherit default $schema dialect for UserProfile', () => { + const user = evaluate('/0/components/schemas/UserProfile', dereferenced); + + expect(user.meta.get('inherited$schema').toValue()).toStrictEqual( + 'https://spec.openapis.org/oas/3.1/dialect/base' + ); + }); + + test('should inherit default $schema dialect for UserProfile.login', () => { + const user = evaluate( + '/0/components/schemas/UserProfile/properties/avatar', + dereferenced + ); + + expect(user.meta.get('inherited$schema').toValue()).toStrictEqual( + 'https://spec.openapis.org/oas/3.1/dialect/base' + ); + }); + }); + + describe('given Schema Objects with unrecognized $schema keyword defined', () => { + const fixturePath = path.join(rootFixturePath, '$schema-unrecognized'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $id keyword defined directly in referencing Schema Object', () => { + const fixturePath = path.join(rootFixturePath, '$id-uri-direct'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $id keyword defined in enclosing Schema Object', () => { + const fixturePath = path.join(rootFixturePath, '$id-uri-enclosing'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $id keyword pointing to external files', () => { + const fixturePath = path.join(rootFixturePath, '$id-uri-external'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with unresolvable $id values', () => { + const fixturePath = path.join(rootFixturePath, '$id-unresolvable'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(ResolverError), + }, + }); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + expect.stringMatching(/\/schemas\/nested\/ex\.json"$/) + ); + }); + }); + + describe('given Schema Objects with $ref keyword containing URL', () => { + const fixturePath = path.join(rootFixturePath, '$ref-url'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing relative references', () => { + const fixturePath = path.join(rootFixturePath, '$ref-url-relative-reference'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing URL and JSON Pointer fragment', () => { + const fixturePath = path.join(rootFixturePath, '$ref-url-pointer'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing URL and $anchor', () => { + const fixturePath = path.join(rootFixturePath, '$ref-url-$anchor'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing resolvable URL', () => { + const fixturePath = path.join(rootFixturePath, '$ref-url-resolvable'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing unresolvable URL', () => { + const fixturePath = path.join(rootFixturePath, '$ref-url-unresolvable'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(ResolverError), + }, + }); + }); + }); + + describe('given Schema Objects with $ref keyword containing Uniform Resource Name', () => { + const fixturePath = path.join(rootFixturePath, '$ref-urn'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing Uniform Resource Name and JSON Pointer fragment', () => { + const fixturePath = path.join(rootFixturePath, '$ref-urn-pointer'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing Uniform Resource Name and $anchor', () => { + const fixturePath = path.join(rootFixturePath, '$ref-urn-$anchor'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $ref keyword containing unresolvable Uniform Resource Name', () => { + const fixturePath = path.join(rootFixturePath, '$ref-urn-unresolvable'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(EvaluationJsonSchemaUriError), + }, + }); + }); + }); + + describe('given Schema Objects with $anchor keyword pointing to internal schema', () => { + const fixturePath = path.join(rootFixturePath, '$anchor-internal'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with $anchor keyword pointing to external schema', () => { + const fixturePath = path.join(rootFixturePath, '$anchor-external'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with various document boundaries', () => { + const fixturePath = path.join(rootFixturePath, 'document-boundaries'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.yml'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('yaml') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects with not found $anchor', () => { + const fixturePath = path.join(rootFixturePath, '$anchor-not-found'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(EvaluationJsonSchema$anchorError), + }, + }); + }); + }); + + describe('given Boolean JSON Schemas', () => { + const fixturePath = path.join(rootFixturePath, 'boolean-json-schema'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + + describe('given Schema Objects and maxDepth of dereference', () => { + const fixturePath = path.join(rootFixturePath, 'max-depth'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { maxDepth: 2 }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(MaximumDereferenceDepthError), + }, + }); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + expect.stringMatching(/__fixtures__\/max-depth\/ex2.json"$/) + ); + }); + }); + + describe('given Schema Objects and maxDepth of resolution', () => { + const fixturePath = path.join(rootFixturePath, 'max-depth'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + resolve: { maxDepth: 2 }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + await expect(dereferenceThunk()).rejects.toMatchObject({ + cause: { + cause: expect.any(MaximumResolverDepthError), + }, + }); + await expect(dereferenceThunk()).rejects.toHaveProperty( + 'cause.cause.message', + expect.stringMatching(/__fixtures__\/max-depth\/ex2.json"$/) + ); + }); + }); + + describe('given Schema Objects with unresolvable reference', () => { + const fixturePath = path.join(rootFixturePath, 'unresolvable-reference'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Schema Objects with invalid JSON Pointer', () => { + const fixturePath = path.join(rootFixturePath, 'invalid-pointer'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Schema Objects with infinite recursion', () => { + const fixturePath = path.join(rootFixturePath, 'infinite-recursion'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Schema Objects with direct circular external reference', () => { + const fixturePath = path.join(rootFixturePath, 'direct-external-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Schema Objects with direct circular internal reference', () => { + const fixturePath = path.join(rootFixturePath, 'direct-internal-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + + describe('given Schema Objects with indirect circular external reference', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-external-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + + describe('and useCircularStructures=false', () => { + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ useCircularStructures: false }), + ], + }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + }); + + describe('given Schema Objects with indirect circular internal reference', () => { + const fixturePath = path.join(rootFixturePath, 'indirect-internal-circular'); + + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + + describe('and useCircularStructures=false', () => { + test('should throw error', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const dereferenceThunk = () => + dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + dereference: { + strategies: [ + OpenApi3_1SwaggerClientDereferenceStrategy({ useCircularStructures: false }), + ], + }, + }); + + await expect(dereferenceThunk()).rejects.toThrow(DereferenceError); + }); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/__fixtures__/components-security-schemes/dereferenced.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/__fixtures__/components-security-schemes/dereferenced.json new file mode 100644 index 0000000000..26efe25eb3 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/__fixtures__/components-security-schemes/dereferenced.json @@ -0,0 +1,19 @@ +[ + { + "openapi": "3.1.0", + "components": { + "securitySchemes": { + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + }, + "api_key2": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + } + } + } +] diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/__fixtures__/components-security-schemes/root.json b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/__fixtures__/components-security-schemes/root.json new file mode 100644 index 0000000000..4addc45cac --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/__fixtures__/components-security-schemes/root.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "components": { + "securitySchemes": { + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + }, + "api_key2": { + "$ref": "#/components/securitySchemes/api_key" + } + } + } +} diff --git a/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/index.js b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/index.js new file mode 100644 index 0000000000..b0dfffa2e4 --- /dev/null +++ b/test/helpers/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/security-schemes-object/index.js @@ -0,0 +1,38 @@ +import path from 'node:path'; +import { toValue } from '@swagger-api/apidom-core'; +import { mediaTypes } from '@swagger-api/apidom-ns-openapi-3-1'; +import { dereference } from '@swagger-api/apidom-reference/configuration/empty'; + +import * as jestSetup from '../__utils__/jest.local.setup.js'; + +const rootFixturePath = path.join(__dirname, '__fixtures__'); + +describe('dereference', () => { + beforeAll(() => { + jestSetup.beforeAll(); + }); + + afterAll(() => { + jestSetup.afterAll(); + }); + + describe('strategies', () => { + describe('openapi-3-1-swagger-client', () => { + describe('Security Scheme Object', () => { + describe('given in components/securitySchemes field', () => { + const fixturePath = path.join(rootFixturePath, 'components-security-schemes'); + + test('should dereference', async () => { + const rootFilePath = path.join(fixturePath, 'root.json'); + const actual = await dereference(rootFilePath, { + parse: { mediaType: mediaTypes.latest('json') }, + }); + const expected = globalThis.loadJsonFile(path.join(fixturePath, 'dereferenced.json')); + + expect(toValue(actual)).toEqual(expected); + }); + }); + }); + }); + }); +}); diff --git a/test/helpers/apidom/reference/parse/parsers/json/index.js b/test/helpers/apidom/reference/parse/parsers/json/index.js index 4df029bc60..7a8a639c8e 100644 --- a/test/helpers/apidom/reference/parse/parsers/json/index.js +++ b/test/helpers/apidom/reference/parse/parsers/json/index.js @@ -110,12 +110,12 @@ describe('JsonParser', () => { describe('sourceMap', () => { describe('given sourceMap enabled', () => { - test('should throw error', () => { + test('should throw error', async () => { const file = File({ uri: '/path/to/file.json', data: '{"prop": "val"}' }); const parser = JsonParser({ sourceMap: true }); - const parseWithSourceMap = () => parser.parse(file); + const parseWithSourceMapThunk = () => parser.parse(file); - expect(parseWithSourceMap).rejects.toThrow( + await expect(parseWithSourceMapThunk()).rejects.toThrow( new ParserError("json-swagger-client parser plugin doesn't support sourceMaps option") ); }); diff --git a/test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/fixtures/sample-api.json b/test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/__fixtures__/sample-api.json similarity index 100% rename from test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/fixtures/sample-api.json rename to test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/__fixtures__/sample-api.json diff --git a/test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js b/test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js index e8abdf190d..70da05d9e4 100644 --- a/test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js +++ b/test/helpers/apidom/reference/parse/parsers/openapi-json-3-1/index.js @@ -67,7 +67,7 @@ describe('OpenApiJson3_1Parser', () => { describe('given file with supported extension', () => { describe('and file data is buffer and can be detected as OpenAPI 3.1.0', () => { test('should return true', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.json'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.json'); const file = File({ uri: '/path/to/open-api.json', data: fs.readFileSync(url), @@ -80,7 +80,7 @@ describe('OpenApiJson3_1Parser', () => { describe('and file data is string and can be detected as OpenAPI 3.1.0', () => { test('should return true', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.json'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.json'); const file = File({ uri: '/path/to/open-api.json', data: fs.readFileSync(url).toString(), @@ -96,7 +96,7 @@ describe('OpenApiJson3_1Parser', () => { describe('parse', () => { describe('given OpenApi 3.1.x JSON data', () => { test('should return parse result', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.json'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.json'); const data = fs.readFileSync(url).toString(); const file = File({ url, @@ -112,7 +112,7 @@ describe('OpenApiJson3_1Parser', () => { describe('given OpenApi 3.1.x JSON data as buffer', () => { test('should return parse result', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.json'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.json'); const data = fs.readFileSync(url); const file = File({ url, @@ -159,12 +159,12 @@ describe('OpenApiJson3_1Parser', () => { describe('sourceMap', () => { describe('given sourceMap enabled', () => { - test('should throw error', () => { + test('should throw error', async () => { const file = File({ uri: '/path/to/file.json', data: '{"prop": "val"}' }); const parser = OpenApiJson3_1Parser({ sourceMap: true }); - const parseWithSourceMap = () => parser.parse(file); + const parseWithSourceMapThunk = () => parser.parse(file); - expect(parseWithSourceMap).rejects.toThrow( + await expect(parseWithSourceMapThunk()).rejects.toThrow( new ParserError( "openapi-json-3-1-swagger-client parser plugin doesn't support sourceMaps option" ) @@ -174,7 +174,7 @@ describe('OpenApiJson3_1Parser', () => { describe('given sourceMap disabled', () => { test('should not decorate ApiDOM with source maps', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.json'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.json'); const data = fs.readFileSync(url).toString(); const file = File({ url, diff --git a/test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/fixtures/sample-api.yaml b/test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/__fixtures__/sample-api.yaml similarity index 100% rename from test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/fixtures/sample-api.yaml rename to test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/__fixtures__/sample-api.yaml diff --git a/test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js b/test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js index 98b9a2b648..586849a504 100644 --- a/test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js +++ b/test/helpers/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js @@ -98,7 +98,7 @@ describe('OpenApiYaml3_1Parser', () => { describe('given file with supported extension', () => { describe('and file data is buffer and can be detected as OpenAPI 3.1.0', () => { test('should return true', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.yaml'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.yaml'); const file = File({ uri: '/path/to/open-api.yaml', data: fs.readFileSync(url), @@ -111,7 +111,7 @@ describe('OpenApiYaml3_1Parser', () => { describe('and file data is string and can be detected as OpenAPI 3.1.0', () => { test('should return true', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.yaml'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.yaml'); const file = File({ uri: '/path/to/open-api.yaml', data: fs.readFileSync(url).toString(), @@ -127,7 +127,7 @@ describe('OpenApiYaml3_1Parser', () => { describe('parse', () => { describe('given OpenApi 3.1.x YAML data', () => { test('should return parse result', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.yaml'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.yaml'); const data = fs.readFileSync(url).toString(); const file = File({ url, @@ -143,7 +143,7 @@ describe('OpenApiYaml3_1Parser', () => { describe('given OpenApi 3.1.x YAML data as buffer', () => { test('should return parse result', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.yaml'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.yaml'); const data = fs.readFileSync(url); const file = File({ url, @@ -190,12 +190,12 @@ describe('OpenApiYaml3_1Parser', () => { describe('sourceMap', () => { describe('given sourceMap enabled', () => { - test('should throw error', () => { + test('should throw error', async () => { const file = File({ uri: '/path/to/file.yaml', data: 'prop: val' }); const parser = OpenApiYaml3_1Parser({ sourceMap: true }); - const parseWithSourceMap = () => parser.parse(file); + const parseWithSourceMapThunk = () => parser.parse(file); - expect(parseWithSourceMap).rejects.toThrow( + await expect(parseWithSourceMapThunk()).rejects.toThrow( new ParserError( "openapi-yaml-3-1-swagger-client parser plugin doesn't support sourceMaps option" ) @@ -205,7 +205,7 @@ describe('OpenApiYaml3_1Parser', () => { describe('given sourceMap disabled', () => { test('should not decorate ApiDOM with source maps', async () => { - const url = path.join(__dirname, 'fixtures', 'sample-api.yaml'); + const url = path.join(__dirname, '__fixtures__', 'sample-api.yaml'); const data = fs.readFileSync(url).toString(); const file = File({ url, diff --git a/test/helpers/apidom/reference/parse/parsers/yaml-1-2/index.js b/test/helpers/apidom/reference/parse/parsers/yaml-1-2/index.js index a628cb8d49..ada3bf9f78 100644 --- a/test/helpers/apidom/reference/parse/parsers/yaml-1-2/index.js +++ b/test/helpers/apidom/reference/parse/parsers/yaml-1-2/index.js @@ -124,7 +124,7 @@ describe('YamlParser', () => { const parser = YamlParser({ sourceMap: true }); const parseWithSourceMap = () => parser.parse(file); - expect(parseWithSourceMap).rejects.toThrow( + expect(parseWithSourceMap()).rejects.toThrow( new ParserError( "yaml-1-2-swagger-client parser plugin doesn't support sourceMaps option" ) diff --git a/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/fixtures/empty-openapi-3-1-api.json b/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/__fixtures__/empty-openapi-3-1-api.json similarity index 100% rename from test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/fixtures/empty-openapi-3-1-api.json rename to test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/__fixtures__/empty-openapi-3-1-api.json diff --git a/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/fixtures/sample-openapi-3-1-api.json b/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/__fixtures__/sample-openapi-3-1-api.json similarity index 100% rename from test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/fixtures/sample-openapi-3-1-api.json rename to test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/__fixtures__/sample-openapi-3-1-api.json diff --git a/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/fixtures/unknown-extension.ext b/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/__fixtures__/unknown-extension.ext similarity index 100% rename from test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/fixtures/unknown-extension.ext rename to test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/__fixtures__/unknown-extension.ext diff --git a/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js b/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js index f3aca7d547..c2ed875ae5 100644 --- a/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js +++ b/test/helpers/apidom/reference/resolve/resolvers/http-swagger-client/index.js @@ -60,41 +60,44 @@ describe('HttpResolverSwaggerClient', () => { const response = new Response(Buffer.from('data'), { status: 400, }); - fetchMock.get(url, response, { repeat: 1 }); + const readThunk = async () => { + fetchMock.get(url, response, { repeat: 1 }); + try { + return await resolver.read(File({ uri: url })); + } finally { + fetchMock.restore(); + } + }; - expect.assertions(2); - try { - await resolver.read(File({ uri: url })); - } catch (error) { - expect(error).toBeInstanceOf(ResolverError); - expect(error).toHaveProperty( - 'message', - 'Error downloading "https://httpbin.org/anything"' - ); - } finally { - fetchMock.restore(); - } + await expect(readThunk()).rejects.toThrow(ResolverError); + await expect(readThunk()).rejects.toHaveProperty( + 'message', + 'Error downloading "https://httpbin.org/anything"' + ); }); test('should throw on timeout', async () => { resolver = HttpResolverSwaggerClient({ timeout: 1 }); const url = 'http://localhost:8123/local-file.txt'; - const cwd = path.join(__dirname, 'fixtures'); - const server = globalThis.createHTTPServer({ port: 8123, cwd }); - - expect.assertions(3); - try { - await resolver.read(File({ uri: url })); - } catch (error) { - expect(error.cause.message).toStrictEqual('The user aborted a request.'); - expect(error).toBeInstanceOf(ResolverError); - expect(error).toHaveProperty( - 'message', - 'Error downloading "http://localhost:8123/local-file.txt"' - ); - } finally { - await server.terminate(); - } + const cwd = path.join(__dirname, '__fixtures__'); + const readThunk = async () => { + const server = globalThis.createHTTPServer({ port: 8123, cwd }); + try { + return await resolver.read(File({ uri: url })); + } finally { + await server.terminate(); + } + }; + + await expect(readThunk()).rejects.toThrow(ResolverError); + await expect(readThunk()).rejects.toHaveProperty( + 'message', + 'Error downloading "http://localhost:8123/local-file.txt"' + ); + await expect(readThunk).rejects.toHaveProperty( + 'cause.message', + 'The user aborted a request.' + ); }); describe('given withCredentials option', () => { @@ -104,17 +107,18 @@ describe('HttpResolverSwaggerClient', () => { }); const url = 'https://httpbin.org/anything'; const response = new Response(Buffer.from('data')); - fetchMock.get(url, response, { repeat: 1 }); - - expect.assertions(1); - try { - await resolver.read(File({ uri: url })); - const [, requestInit] = fetchMock.lastCall(url); - - expect(requestInit).toHaveProperty('credentials', 'include'); - } finally { - fetchMock.restore(); - } + const readThunk = async () => { + fetchMock.get(url, response, { repeat: 1 }); + try { + await resolver.read(File({ uri: url })); + const [, requestInit] = fetchMock.lastCall(url); + return requestInit; + } finally { + fetchMock.restore(); + } + }; + + await expect(readThunk()).resolves.toHaveProperty('credentials', 'include'); }); }); @@ -122,21 +126,22 @@ describe('HttpResolverSwaggerClient', () => { test('should allow cross-site Access-Control requests', async () => { const url = 'https://httpbin.org/anything'; const response = new Response(Buffer.from('data')); - fetchMock.get(url, response, { repeat: 1 }); const { withCredentials: originalWithCredentials } = Http; - - Http.withCredentials = true; - - expect.assertions(1); - try { - await resolver.read(File({ uri: url })); - const [, requestInit] = fetchMock.lastCall(url); - - expect(requestInit).toHaveProperty('credentials', 'include'); - } finally { - fetchMock.restore(); - Http.withCredentials = originalWithCredentials; - } + const readThunk = async () => { + fetchMock.get(url, response, { repeat: 1 }); + Http.withCredentials = true; + + try { + await resolver.read(File({ uri: url })); + const [, requestInit] = fetchMock.lastCall(url); + return requestInit; + } finally { + fetchMock.restore(); + Http.withCredentials = originalWithCredentials; + } + }; + + await expect(readThunk()).resolves.toHaveProperty('credentials', 'include'); }); }); diff --git a/test/jest.setup.js b/test/jest.setup.js index 82fb598257..30ded100e3 100644 --- a/test/jest.setup.js +++ b/test/jest.setup.js @@ -15,6 +15,10 @@ fetchMock.config.Headers = Headers; // provide AbortController for older Node.js versions globalThis.AbortController = globalThis.AbortController ?? AbortController; +// helpers for reading local files +globalThis.loadFile = (uri) => fs.readFileSync(uri).toString(); +globalThis.loadJsonFile = (uri) => JSON.parse(globalThis.loadFile(uri)); + // helper for providing HTTP server instance for testing globalThis.createHTTPServer = ({ port = 8123, cwd = process.cwd() } = {}) => { const server = http.createServer((req, res) => {