@redocly/openapi-core
Advanced tools
Comparing version 1.25.7 to 1.25.8
# @redocly/openapi-core | ||
## 1.25.8 | ||
### Patch Changes | ||
- Fixed bundling with the `--dereferenced` option. Previously, references to external files were not substituted with references to components, causing them to become invalid. | ||
- Fixed an issue where using `externalValue` as a property name was causing the API description validation process to fail. | ||
## 1.25.7 | ||
@@ -4,0 +11,0 @@ |
@@ -316,8 +316,3 @@ "use strict"; | ||
const componentType = mapTypeToComponent('Schema', version); | ||
if (dereference) { | ||
saveComponent(componentType, resolved, ctx); | ||
} | ||
else { | ||
mapping[name] = saveComponent(componentType, resolved, ctx); | ||
} | ||
mapping[name] = saveComponent(componentType, resolved, ctx); | ||
} | ||
@@ -341,8 +336,7 @@ }, | ||
components[componentType][name] = target.node; | ||
if (version === oas_types_1.SpecMajorVersion.OAS3) { | ||
if (version === oas_types_1.SpecMajorVersion.OAS3 || | ||
version === oas_types_1.SpecMajorVersion.Async2 || | ||
version === oas_types_1.SpecMajorVersion.Async3) { | ||
return `#/components/${componentType}/${name}`; | ||
} | ||
else if (version === oas_types_1.SpecMajorVersion.Async2 || version === oas_types_1.SpecMajorVersion.Async3) { | ||
return `#/components/${componentType}/${name}`; | ||
} | ||
else { | ||
@@ -349,0 +343,0 @@ return `#/${componentType}/${name}`; |
import type { Source } from './resolve'; | ||
import type { OasRef } from './typings/openapi'; | ||
export declare function joinPointer(base: string, key: string | number): string; | ||
export declare function isRef(node: any): node is OasRef; | ||
export declare function isRef(node: unknown): node is OasRef; | ||
export declare function isExternalValue(node: unknown): boolean; | ||
export declare class Location { | ||
@@ -6,0 +7,0 @@ source: Source; |
@@ -6,2 +6,3 @@ "use strict"; | ||
exports.isRef = isRef; | ||
exports.isExternalValue = isExternalValue; | ||
exports.unescapePointer = unescapePointer; | ||
@@ -23,4 +24,7 @@ exports.escapePointer = escapePointer; | ||
function isRef(node) { | ||
return node && typeof node.$ref === 'string'; | ||
return (0, utils_1.isPlainObject)(node) && typeof node.$ref === 'string'; | ||
} | ||
function isExternalValue(node) { | ||
return (0, utils_1.isPlainObject)(node) && typeof node.externalValue === 'string'; | ||
} | ||
class Location { | ||
@@ -27,0 +31,0 @@ constructor(source, pointer) { |
@@ -250,3 +250,3 @@ "use strict"; | ||
// handle example.externalValue as reference | ||
if (node.externalValue) { | ||
if ((0, ref_utils_1.isExternalValue)(node)) { | ||
const promise = followRef(rootNodeDocument, { $ref: node.externalValue }, { | ||
@@ -253,0 +253,0 @@ prev: null, |
{ | ||
"name": "@redocly/openapi-core", | ||
"version": "1.25.7", | ||
"version": "1.25.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -259,2 +259,11 @@ import outdent from 'outdent'; | ||
}); | ||
it('should bundle schemas with properties named $ref and externalValues correctly', async () => { | ||
const { bundle: res, problems } = await bundle({ | ||
config: new Config({} as ResolvedConfig), | ||
ref: path.join(__dirname, 'fixtures/refs/openapi-with-special-names-in-props.yaml'), | ||
}); | ||
expect(problems).toHaveLength(0); | ||
expect(res.parsed).toMatchSnapshot(); | ||
}); | ||
}); | ||
@@ -261,0 +270,0 @@ |
@@ -430,7 +430,3 @@ import { BaseResolver, resolveDocument, makeRefId, makeDocumentFromString } from './resolve'; | ||
const componentType = mapTypeToComponent('Schema', version)!; | ||
if (dereference) { | ||
saveComponent(componentType, resolved, ctx); | ||
} else { | ||
mapping[name] = saveComponent(componentType, resolved, ctx); | ||
} | ||
mapping[name] = saveComponent(componentType, resolved, ctx); | ||
} | ||
@@ -460,6 +456,8 @@ }, | ||
components[componentType][name] = target.node; | ||
if (version === SpecMajorVersion.OAS3) { | ||
if ( | ||
version === SpecMajorVersion.OAS3 || | ||
version === SpecMajorVersion.Async2 || | ||
version === SpecMajorVersion.Async3 | ||
) { | ||
return `#/components/${componentType}/${name}`; | ||
} else if (version === SpecMajorVersion.Async2 || version === SpecMajorVersion.Async3) { | ||
return `#/components/${componentType}/${name}`; | ||
} else { | ||
@@ -466,0 +464,0 @@ return `#/${componentType}/${name}`; |
@@ -1,2 +0,2 @@ | ||
import { isTruthy } from './utils'; | ||
import { isPlainObject, isTruthy } from './utils'; | ||
@@ -11,6 +11,10 @@ import type { Source } from './resolve'; | ||
export function isRef(node: any): node is OasRef { | ||
return node && typeof node.$ref === 'string'; | ||
export function isRef(node: unknown): node is OasRef { | ||
return isPlainObject(node) && typeof node.$ref === 'string'; | ||
} | ||
export function isExternalValue(node: unknown) { | ||
return isPlainObject(node) && typeof node.externalValue === 'string'; | ||
} | ||
export class Location { | ||
@@ -17,0 +21,0 @@ constructor(public source: Source, public pointer: string) {} |
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { isRef, joinPointer, escapePointer, parseRef, isAbsoluteUrl, isAnchor } from './ref-utils'; | ||
import { | ||
isRef, | ||
joinPointer, | ||
escapePointer, | ||
parseRef, | ||
isAbsoluteUrl, | ||
isAnchor, | ||
isExternalValue, | ||
} from './ref-utils'; | ||
import { isNamedType, SpecExtension } from './types'; | ||
@@ -340,3 +348,3 @@ import { readFileFromUrl, parseYaml, nextTick } from './utils'; | ||
// handle example.externalValue as reference | ||
if (node.externalValue) { | ||
if (isExternalValue(node)) { | ||
const promise = followRef( | ||
@@ -343,0 +351,0 @@ rootNodeDocument, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3039423
670
54575