@scalar/oas-utils
Advanced tools
Comparing version 0.2.78 to 0.2.79
# @scalar/oas-utils | ||
## 0.2.79 | ||
### Patch Changes | ||
- 6dd7eda: fix: catch errors for invalid OpenAPI documents | ||
- Updated dependencies [1b06f64] | ||
- @scalar/themes@0.9.50 | ||
## 0.2.78 | ||
@@ -4,0 +12,0 @@ |
@@ -8,4 +8,11 @@ import { type Collection, type CollectionPayload, type Request, type RequestExample, type Server, type Tag } from '../entities/spec/index.js'; | ||
export declare const parseSchema: (spec: string | UnknownObject) => Promise<{ | ||
/** | ||
* Temporary fix for the parser returning an empty array | ||
* TODO: remove this once the parser is fixed | ||
*/ | ||
schema: OpenAPIV3.Document | OpenAPIV3_1.Document; | ||
errors: import("@scalar/openapi-parser").ErrorObject[]; | ||
errors: ({ | ||
code: any; | ||
message: any; | ||
} | import("@scalar/openapi-parser").ErrorObject)[]; | ||
}>; | ||
@@ -12,0 +19,0 @@ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers'> & { |
@@ -15,6 +15,23 @@ import { securitySchemeSchema } from '../entities/spec/security.js'; | ||
// @see packages/api-reference/src/helpers/parse.ts | ||
const { filesystem } = await load(spec); | ||
const { filesystem, errors: loadErrors = [] } = await load(spec).catch((e) => ({ | ||
errors: [ | ||
{ | ||
code: e.code, | ||
message: e.message, | ||
}, | ||
], | ||
filesystem: [], | ||
})); | ||
const { specification } = upgrade(filesystem); | ||
const { schema, errors = [] } = await dereference(specification); | ||
return { schema: schema, errors }; | ||
const { schema, errors: derefErrors = [] } = await dereference(specification); | ||
if (!schema) | ||
console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined'); | ||
return { | ||
/** | ||
* Temporary fix for the parser returning an empty array | ||
* TODO: remove this once the parser is fixed | ||
*/ | ||
schema: (Array.isArray(schema) ? {} : schema), | ||
errors: [...loadErrors, ...derefErrors], | ||
}; | ||
}; | ||
@@ -21,0 +38,0 @@ /** |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.2.78", | ||
"version": "0.2.79", | ||
"engines": { | ||
@@ -116,5 +116,5 @@ "node": ">=18" | ||
"@scalar/object-utils": "1.1.12", | ||
"@scalar/themes": "0.9.49", | ||
"@scalar/types": "0.0.20", | ||
"@scalar/openapi-types": "0.1.5" | ||
"@scalar/openapi-types": "0.1.5", | ||
"@scalar/themes": "0.9.50", | ||
"@scalar/types": "0.0.20" | ||
}, | ||
@@ -127,4 +127,4 @@ "devDependencies": { | ||
"@scalar/build-tooling": "0.1.12", | ||
"@scalar/openapi-types": "0.1.5", | ||
"@scalar/openapi-parser": "0.8.10" | ||
"@scalar/openapi-parser": "0.8.10", | ||
"@scalar/openapi-types": "0.1.5" | ||
}, | ||
@@ -131,0 +131,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
453082
9237
+ Added@scalar/themes@0.9.50(transitive)
- Removed@scalar/themes@0.9.49(transitive)
Updated@scalar/themes@0.9.50