@kubb/oas 4.33.4 → 4.34.0
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/chunk--u3MIqq1.js +8 -0
- package/dist/index.cjs +251 -4390
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +95 -24
- package/dist/index.js +246 -4379
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/Oas.ts +33 -3
- package/src/constants.ts +88 -0
- package/src/index.ts +1 -0
- package/src/parser.ts +1163 -0
- package/src/types.ts +15 -10
- package/src/utils.ts +34 -17
- package/dist/chunk-OuPHjz6n.js +0 -41
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,93 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import BaseOas from "oas";
|
|
3
3
|
import * as OasTypes from "oas/types";
|
|
4
|
-
import { DiscriminatorObject as DiscriminatorObject$1, HttpMethods
|
|
4
|
+
import { DiscriminatorObject as DiscriminatorObject$1, HttpMethods, MediaTypeObject as MediaTypeObject$1, OASDocument, ParameterObject, ResponseObject as ResponseObject$1, SchemaObject as SchemaObject$1 } from "oas/types";
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import { Operation as Operation$1 } from "oas/operation";
|
|
7
7
|
import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1, OpenAPIV3_1 as OpenAPIV3_1$1 } from "openapi-types";
|
|
8
8
|
import { Config } from "@kubb/core";
|
|
9
9
|
|
|
10
|
+
//#region src/constants.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* JSON Schema keywords that indicate structural composition.
|
|
13
|
+
* Used when deciding whether an inline `allOf` fragment can be safely flattened
|
|
14
|
+
* into its parent (fragments containing any of these keys must not be inlined).
|
|
15
|
+
*/
|
|
16
|
+
declare const STRUCTURAL_KEYS: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Maps OAS/JSON Schema `format` strings to their Kubb `SchemaType` equivalents.
|
|
19
|
+
*
|
|
20
|
+
* Only formats that require a type different from the raw OAS `type` are listed here.
|
|
21
|
+
* `int64`, `date-time`, `date`, and `time` are handled separately because their
|
|
22
|
+
* output depends on runtime parser options and cannot live in a static map.
|
|
23
|
+
*
|
|
24
|
+
* Note: `ipv4`, `ipv6`, and `hostname` map to `'url'` — not semantically accurate,
|
|
25
|
+
* but `'url'` is the closest supported scalar type in the Kubb AST.
|
|
26
|
+
*/
|
|
27
|
+
declare const FORMAT_MAP: {
|
|
28
|
+
readonly uuid: "uuid";
|
|
29
|
+
readonly email: "email";
|
|
30
|
+
readonly 'idn-email': "email";
|
|
31
|
+
readonly uri: "url";
|
|
32
|
+
readonly 'uri-reference': "url";
|
|
33
|
+
readonly url: "url";
|
|
34
|
+
readonly ipv4: "url";
|
|
35
|
+
readonly ipv6: "url";
|
|
36
|
+
readonly hostname: "url";
|
|
37
|
+
readonly 'idn-hostname': "url";
|
|
38
|
+
readonly binary: "blob";
|
|
39
|
+
readonly byte: "blob";
|
|
40
|
+
readonly int32: "integer";
|
|
41
|
+
readonly float: "number";
|
|
42
|
+
readonly double: "number";
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Exhaustive list of media types that Kubb recognizes.
|
|
46
|
+
* Kept as a module-level constant to avoid re-allocating the array on every call.
|
|
47
|
+
*/
|
|
48
|
+
declare const KNOWN_MEDIA_TYPES: readonly ["application/json", "application/xml", "application/x-www-form-urlencoded", "application/octet-stream", "application/pdf", "application/zip", "application/graphql", "multipart/form-data", "text/plain", "text/html", "text/csv", "text/xml", "image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml", "audio/mpeg", "video/mp4"];
|
|
49
|
+
/**
|
|
50
|
+
* Vendor extension keys used by various spec generators to attach human-readable
|
|
51
|
+
* labels to enum values. Checked in priority order: the first key found wins.
|
|
52
|
+
*/
|
|
53
|
+
declare const ENUM_EXTENSION_KEYS: readonly ["x-enumNames", "x-enum-varnames"];
|
|
54
|
+
/**
|
|
55
|
+
* Canonical HTTP method names used throughout the Kubb OAS layer.
|
|
56
|
+
* Keys are uppercase (as used in generated code); values are the lowercase
|
|
57
|
+
* strings that the `oas` library uses internally.
|
|
58
|
+
* @deprecated use httpMethods from @kubb/ast
|
|
59
|
+
*/
|
|
60
|
+
declare const httpMethods: {
|
|
61
|
+
readonly GET: "get";
|
|
62
|
+
readonly POST: "post";
|
|
63
|
+
readonly PUT: "put";
|
|
64
|
+
readonly PATCH: "patch";
|
|
65
|
+
readonly DELETE: "delete";
|
|
66
|
+
readonly HEAD: "head";
|
|
67
|
+
readonly OPTIONS: "options";
|
|
68
|
+
readonly TRACE: "trace";
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
10
71
|
//#region src/types.d.ts
|
|
11
72
|
type contentType = 'application/json' | (string & {});
|
|
12
73
|
type SchemaObject = SchemaObject$1 & {
|
|
74
|
+
/**
|
|
75
|
+
* OAS 3.1 extension: allows marking a schema as nullable even when `type` does not include `'null'`.
|
|
76
|
+
*/
|
|
13
77
|
'x-nullable'?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* OAS 3.1: constrains the schema to a single fixed value.
|
|
80
|
+
* Semantically equivalent to a one-item `enum`.
|
|
81
|
+
*/
|
|
82
|
+
const?: string | number | boolean | null;
|
|
83
|
+
/**
|
|
84
|
+
* OAS 3.1: specifies the media type of the schema content.
|
|
85
|
+
* When set to `'application/octet-stream'` on a `string` schema, the schema is treated as binary (`blob`).
|
|
86
|
+
*/
|
|
87
|
+
contentMediaType?: string;
|
|
14
88
|
$ref?: string;
|
|
15
89
|
};
|
|
16
|
-
|
|
17
|
-
GET: "get";
|
|
18
|
-
POST: "post";
|
|
19
|
-
PUT: "put";
|
|
20
|
-
PATCH: "patch";
|
|
21
|
-
DELETE: "delete";
|
|
22
|
-
HEAD: "head";
|
|
23
|
-
OPTIONS: "options";
|
|
24
|
-
TRACE: "trace";
|
|
25
|
-
};
|
|
26
|
-
type HttpMethod = HttpMethods$1;
|
|
90
|
+
type HttpMethod = HttpMethods;
|
|
27
91
|
type Document = OASDocument;
|
|
28
92
|
type Operation = Operation$1;
|
|
29
93
|
type DiscriminatorObject = DiscriminatorObject$1;
|
|
@@ -95,24 +159,31 @@ type ServerObject = {
|
|
|
95
159
|
declare function resolveServerUrl(server: ServerObject, overrides?: Record<string, string>): string;
|
|
96
160
|
//#endregion
|
|
97
161
|
//#region src/utils.d.ts
|
|
98
|
-
|
|
99
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Returns `true` when `doc` is an OpenAPI 3.1 document.
|
|
164
|
+
*/
|
|
165
|
+
declare function isOpenApiV3_1Document(doc: unknown): doc is OpenAPIV3_1$1.Document;
|
|
166
|
+
/**
|
|
167
|
+
* Returns `true` when `obj` is a parameter object (has an `in` field distinguishing it from a schema).
|
|
168
|
+
*/
|
|
169
|
+
declare function isParameterObject(obj: ParameterObject | SchemaObject): obj is ParameterObject;
|
|
100
170
|
/**
|
|
101
171
|
* Determines if a schema is nullable, considering:
|
|
102
172
|
* - OpenAPI 3.0 `nullable` / `x-nullable`
|
|
103
173
|
* - OpenAPI 3.1 JSON Schema `type: ['null', ...]` or `type: 'null'`
|
|
104
174
|
*/
|
|
105
|
-
declare function isNullable(schema?: SchemaObject
|
|
175
|
+
declare function isNullable(schema?: SchemaObject & {
|
|
106
176
|
'x-nullable'?: boolean;
|
|
107
177
|
}): boolean;
|
|
108
178
|
/**
|
|
109
|
-
*
|
|
179
|
+
* Returns `true` when `obj` is an OpenAPI `$ref` pointer object.
|
|
110
180
|
*/
|
|
111
|
-
declare function isReference(obj?:
|
|
181
|
+
declare function isReference(obj?: unknown): obj is OpenAPIV3$1.ReferenceObject | OpenAPIV3_1$1.ReferenceObject;
|
|
112
182
|
/**
|
|
113
|
-
*
|
|
183
|
+
* Returns `true` when `obj` is a schema that carries a structured `discriminator` object
|
|
184
|
+
* (as opposed to a plain string discriminator used in some older specs).
|
|
114
185
|
*/
|
|
115
|
-
declare function isDiscriminator(obj?:
|
|
186
|
+
declare function isDiscriminator(obj?: unknown): obj is SchemaObject & {
|
|
116
187
|
discriminator: OpenAPIV3$1.DiscriminatorObject;
|
|
117
188
|
};
|
|
118
189
|
/**
|
|
@@ -120,9 +191,9 @@ declare function isDiscriminator(obj?: any): obj is SchemaObject$1 & {
|
|
|
120
191
|
*
|
|
121
192
|
* Returns true if the schema has a non-empty {@link SchemaObject.required} array or a truthy {@link SchemaObject.required} property.
|
|
122
193
|
*/
|
|
123
|
-
declare function isRequired(schema?: SchemaObject
|
|
194
|
+
declare function isRequired(schema?: SchemaObject): boolean;
|
|
124
195
|
declare function isAllOptional(schema: unknown): boolean;
|
|
125
|
-
declare function isOptional(schema?: SchemaObject
|
|
196
|
+
declare function isOptional(schema?: SchemaObject): boolean;
|
|
126
197
|
/**
|
|
127
198
|
* Determines the appropriate default value for a schema parameter.
|
|
128
199
|
* - For array types: returns '[]'
|
|
@@ -133,7 +204,7 @@ declare function isOptional(schema?: SchemaObject$1): boolean;
|
|
|
133
204
|
* - For primitive types (string, number, boolean): returns undefined (no default)
|
|
134
205
|
* - For required types: returns undefined (no default)
|
|
135
206
|
*/
|
|
136
|
-
declare function getDefaultValue(schema?: SchemaObject
|
|
207
|
+
declare function getDefaultValue(schema?: SchemaObject): string | undefined;
|
|
137
208
|
declare function parse(pathOrApi: string | Document, {
|
|
138
209
|
oasClass,
|
|
139
210
|
canBundle,
|
|
@@ -154,5 +225,5 @@ declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise
|
|
|
154
225
|
*/
|
|
155
226
|
declare function validate(document: Document): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
156
227
|
//#endregion
|
|
157
|
-
export { DiscriminatorObject, Document, HttpMethod, HttpMethods, KUBB_INLINE_REF_PREFIX, MediaTypeObject, Oas, type OasTypes, type OpenAPIV3, type OpenAPIV3_1, Operation, ReferenceObject, ResponseObject, SchemaObject, contentType, getDefaultValue, isAllOptional, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, merge, parse, parseFromConfig, resolveServerUrl, validate };
|
|
228
|
+
export { DiscriminatorObject, Document, ENUM_EXTENSION_KEYS, FORMAT_MAP, HttpMethod, httpMethods as HttpMethods, httpMethods, KNOWN_MEDIA_TYPES, KUBB_INLINE_REF_PREFIX, MediaTypeObject, Oas, type OasTypes, type OpenAPIV3, type OpenAPIV3_1, Operation, ReferenceObject, ResponseObject, STRUCTURAL_KEYS, SchemaObject, contentType, getDefaultValue, isAllOptional, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, merge, parse, parseFromConfig, resolveServerUrl, validate };
|
|
158
229
|
//# sourceMappingURL=index.d.ts.map
|