@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/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 && itemsType === undefined) {
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, open 'invalid.yaml'",
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 [],