@kubb/adapter-oas 5.0.0-alpha.36 → 5.0.0-alpha.39
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/dist/index.cjs +21 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +147 -3
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/factory.ts +10 -2
- package/src/index.ts +17 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/adapter-oas",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.39",
|
|
4
4
|
"description": "OpenAPI / Swagger adapter for Kubb converts OAS input into a @kubb/ast RootNode.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"!/**/__snapshots__/**"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@redocly/openapi-core": "^2.28.
|
|
39
|
+
"@redocly/openapi-core": "^2.28.1",
|
|
40
40
|
"@stoplight/yaml": "^4.3.0",
|
|
41
41
|
"fflate": "^0.8.2",
|
|
42
42
|
"jsonpointer": "^5.0.1",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"openapi-types": "^12.1.3",
|
|
46
46
|
"remeda": "^2.33.7",
|
|
47
47
|
"swagger2openapi": "^7.0.8",
|
|
48
|
-
"@kubb/core": "5.0.0-alpha.
|
|
48
|
+
"@kubb/core": "5.0.0-alpha.39"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/swagger2openapi": "^7.0.4",
|
package/src/factory.ts
CHANGED
|
@@ -15,6 +15,10 @@ export type ParseOptions = {
|
|
|
15
15
|
enablePaths?: boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export type ValidateDocumentOptions = {
|
|
19
|
+
throwOnError?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* Loads and dereferences an OpenAPI document, returning the raw `Document`.
|
|
20
24
|
*
|
|
@@ -134,7 +138,7 @@ export function parseFromConfig(source: AdapterSource): Promise<Document> {
|
|
|
134
138
|
* await validateDocument(document)
|
|
135
139
|
* ```
|
|
136
140
|
*/
|
|
137
|
-
export async function validateDocument(document: Document): Promise<void> {
|
|
141
|
+
export async function validateDocument(document: Document, { throwOnError = false }: ValidateDocumentOptions = {}): Promise<void> {
|
|
138
142
|
try {
|
|
139
143
|
const oasNormalize = new OASNormalize(document, {
|
|
140
144
|
enablePaths: true,
|
|
@@ -148,7 +152,11 @@ export async function validateDocument(document: Document): Promise<void> {
|
|
|
148
152
|
},
|
|
149
153
|
},
|
|
150
154
|
})
|
|
151
|
-
} catch (
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (throwOnError) {
|
|
157
|
+
throw error
|
|
158
|
+
}
|
|
159
|
+
|
|
152
160
|
// Validation failures are non-fatal — mirror plugin-oas behavior
|
|
153
161
|
}
|
|
154
162
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
export { adapterOas, adapterOasName } from './adapter.ts'
|
|
2
|
-
export
|
|
2
|
+
export { mergeDocuments, parseDocument, parseFromConfig, validateDocument } from './factory.ts'
|
|
3
|
+
export { HttpMethods } from './types.ts'
|
|
4
|
+
export type {
|
|
5
|
+
AdapterOas,
|
|
6
|
+
AdapterOasOptions,
|
|
7
|
+
AdapterOasResolvedOptions,
|
|
8
|
+
ContentType,
|
|
9
|
+
DiscriminatorObject,
|
|
10
|
+
Document,
|
|
11
|
+
HttpMethod,
|
|
12
|
+
MediaTypeObject,
|
|
13
|
+
Operation,
|
|
14
|
+
ReferenceObject,
|
|
15
|
+
ResponseObject,
|
|
16
|
+
SchemaObject,
|
|
17
|
+
} from './types.ts'
|
|
18
|
+
export type { ParseOptions, ValidateDocumentOptions } from './factory.ts'
|