@scalar/oas-utils 0.2.78 → 0.2.80

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.80
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9d23f95]
8
+ - Updated dependencies [91123e8]
9
+ - @scalar/types@0.0.21
10
+ - @scalar/themes@0.9.51
11
+
12
+ ## 0.2.79
13
+
14
+ ### Patch Changes
15
+
16
+ - 6dd7eda: fix: catch errors for invalid OpenAPI documents
17
+ - Updated dependencies [1b06f64]
18
+ - @scalar/themes@0.9.50
19
+
3
20
  ## 0.2.78
4
21
 
5
22
  ### Patch Changes
@@ -5,8 +5,15 @@ import type { ReferenceConfiguration } from '@scalar/types/legacy';
5
5
  import type { UnknownObject } from '@scalar/types/utils';
6
6
  /** Takes a string or object and parses it into an openapi spec compliant schema */
7
7
  export declare const parseSchema: (spec: string | UnknownObject) => Promise<{
8
+ /**
9
+ * Temporary fix for the parser returning an empty array
10
+ * TODO: remove this once the parser is fixed
11
+ */
8
12
  schema: OpenAPIV3.Document | OpenAPIV3_1.Document;
9
- errors: import("@scalar/openapi-parser").ErrorObject[];
13
+ errors: ({
14
+ code: any;
15
+ message: any;
16
+ } | import("@scalar/openapi-parser").ErrorObject)[];
10
17
  }>;
11
18
  export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers'> & {
12
19
  /** Sets the preferred security scheme on the collection instead of the requests */
@@ -1 +1 @@
1
- {"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX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QAAQ,CAAA;IACjD,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAC5C,CAuVA"}
@@ -12,10 +12,27 @@ import { collectionSchema } from '../entities/spec/collection.js';
12
12
  const parseSchema = async (spec) => {
13
13
  // TODO: Plugins for URLs and files with the proxy is missing here.
14
14
  // @see packages/api-reference/src/helpers/parse.ts
15
- const { filesystem } = await load(spec);
15
+ const { filesystem, errors: loadErrors = [] } = await load(spec).catch((e) => ({
16
+ errors: [
17
+ {
18
+ code: e.code,
19
+ message: e.message,
20
+ },
21
+ ],
22
+ filesystem: [],
23
+ }));
16
24
  const { specification } = upgrade(filesystem);
17
- const { schema, errors = [] } = await dereference(specification);
18
- return { schema: schema, errors };
25
+ const { schema, errors: derefErrors = [] } = await dereference(specification);
26
+ if (!schema)
27
+ console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined');
28
+ return {
29
+ /**
30
+ * Temporary fix for the parser returning an empty array
31
+ * TODO: remove this once the parser is fixed
32
+ */
33
+ schema: (Array.isArray(schema) ? {} : schema),
34
+ errors: [...loadErrors, ...derefErrors],
35
+ };
19
36
  };
20
37
  /**
21
38
  * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.78",
19
+ "version": "0.2.80",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -112,18 +112,18 @@
112
112
  "yaml": "^2.4.5",
113
113
  "zod": "^3.23.8",
114
114
  "@scalar/object-utils": "1.1.12",
115
- "@scalar/themes": "0.9.49",
116
- "@scalar/types": "0.0.20",
117
- "@scalar/openapi-types": "0.1.5"
115
+ "@scalar/types": "0.0.21",
116
+ "@scalar/openapi-types": "0.1.5",
117
+ "@scalar/themes": "0.9.51"
118
118
  },
119
119
  "devDependencies": {
120
120
  "type-fest": "^4.20.0",
121
121
  "vite": "^5.4.10",
122
122
  "vitest": "^1.6.0",
123
123
  "zod-to-ts": "github:amritk/zod-to-ts#build",
124
- "@scalar/build-tooling": "0.1.12",
125
124
  "@scalar/openapi-types": "0.1.5",
126
- "@scalar/openapi-parser": "0.8.10"
125
+ "@scalar/openapi-parser": "0.8.10",
126
+ "@scalar/build-tooling": "0.1.12"
127
127
  },
128
128
  "scripts": {
129
129
  "build": "scalar-build-rollup",