@redocly/openapi-core 1.0.0-beta.124 → 1.0.0-beta.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundle.d.ts +7 -12
- package/lib/config/all.js +8 -1
- package/lib/config/types.d.ts +5 -1
- package/lib/resolve.js +5 -1
- package/lib/rules/common/assertions/asserts.d.ts +6 -2
- package/lib/rules/common/assertions/asserts.js +30 -20
- package/lib/rules/common/assertions/utils.d.ts +8 -0
- package/lib/rules/common/assertions/utils.js +28 -34
- package/lib/rules/common/required-string-property-missing-min-length.d.ts +2 -0
- package/lib/rules/common/required-string-property-missing-min-length.js +37 -0
- package/lib/rules/oas2/index.d.ts +1 -0
- package/lib/rules/oas2/index.js +2 -0
- package/lib/rules/oas3/index.js +2 -0
- package/lib/types/redocly-yaml.js +1 -0
- package/package.json +1 -1
- package/src/__tests__/resolve.test.ts +22 -0
- package/src/bundle.ts +11 -2
- package/src/config/all.ts +8 -1
- package/src/config/types.ts +4 -1
- package/src/resolve.ts +6 -1
- package/src/rules/__tests__/no-unresolved-refs.test.ts +1 -1
- package/src/rules/common/assertions/__tests__/asserts.test.ts +264 -178
- package/src/rules/common/assertions/__tests__/index.test.ts +1 -1
- package/src/rules/common/assertions/__tests__/utils.test.ts +122 -1
- package/src/rules/common/assertions/asserts.ts +59 -28
- package/src/rules/common/assertions/utils.ts +46 -44
- package/src/rules/common/required-string-property-missing-min-length.ts +44 -0
- package/src/rules/oas2/index.ts +2 -0
- package/src/rules/oas3/index.ts +2 -0
- package/src/types/redocly-yaml.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/resolve.ts
CHANGED
|
@@ -115,11 +115,15 @@ export class BaseResolver {
|
|
|
115
115
|
const { body, mimeType } = await readFileFromUrl(absoluteRef, this.config.http);
|
|
116
116
|
return new Source(absoluteRef, body, mimeType);
|
|
117
117
|
} else {
|
|
118
|
+
if (fs.lstatSync(absoluteRef).isDirectory()) {
|
|
119
|
+
throw new Error(`Expected a file but received a folder at ${absoluteRef}`);
|
|
120
|
+
}
|
|
118
121
|
const content = await fs.promises.readFile(absoluteRef, 'utf-8');
|
|
119
122
|
// In some cases file have \r\n line delimeters like on windows, we should skip it.
|
|
120
123
|
return new Source(absoluteRef, content.replace(/\r\n/g, '\n'));
|
|
121
124
|
}
|
|
122
125
|
} catch (error) {
|
|
126
|
+
error.message = error.message.replace(', lstat', '');
|
|
123
127
|
throw new ResolveError(error);
|
|
124
128
|
}
|
|
125
129
|
}
|
|
@@ -150,6 +154,7 @@ export class BaseResolver {
|
|
|
150
154
|
isRoot: boolean = false
|
|
151
155
|
): Promise<Document | ResolveError | YamlParseError> {
|
|
152
156
|
const absoluteRef = this.resolveExternalRef(base, ref);
|
|
157
|
+
|
|
153
158
|
const cachedDocument = this.cache.get(absoluteRef);
|
|
154
159
|
if (cachedDocument) {
|
|
155
160
|
return cachedDocument;
|
|
@@ -261,7 +266,7 @@ export async function resolveDocument(opts: {
|
|
|
261
266
|
if (Array.isArray(node)) {
|
|
262
267
|
const itemsType = type.items;
|
|
263
268
|
// we continue resolving unknown types, but stop early on known scalars
|
|
264
|
-
if (type !== unknownType &&
|
|
269
|
+
if (itemsType === undefined && type !== unknownType && type !== SpecExtension) {
|
|
265
270
|
return;
|
|
266
271
|
}
|
|
267
272
|
for (let i = 0; i < node.length; i++) {
|
|
@@ -36,7 +36,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
36
36
|
"source": "foobar.yaml",
|
|
37
37
|
},
|
|
38
38
|
],
|
|
39
|
-
"message": "Can't resolve $ref: ENOENT: no such file or directory
|
|
39
|
+
"message": "Can't resolve $ref: ENOENT: no such file or directory 'invalid.yaml'",
|
|
40
40
|
"ruleId": "no-unresolved-refs",
|
|
41
41
|
"severity": "error",
|
|
42
42
|
"suggest": Array [],
|