@kubb/oas 4.33.5 → 4.35.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/index.d.ts CHANGED
@@ -1,40 +1,93 @@
1
- import { i as __name } from "./chunk-OuPHjz6n.js";
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 as HttpMethods$1, MediaTypeObject as MediaTypeObject$1, OASDocument, ParameterObject, ResponseObject as ResponseObject$1, SchemaObject as SchemaObject$1 } from "oas/types";
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 & {
13
74
  /**
14
- * Oas 3.1 adds support for `x-nullable` to specify that a schema can be null, even if `type` does not include `null`.
75
+ * OAS 3.1 extension: allows marking a schema as nullable even when `type` does not include `'null'`.
15
76
  */
16
77
  'x-nullable'?: boolean;
17
78
  /**
18
- * Oas 3.1 adds support for `const` to specify that a schema can only have a single value, which must be equal to the value of `const`.
79
+ * OAS 3.1: constrains the schema to a single fixed value.
80
+ * Semantically equivalent to a one-item `enum`.
19
81
  */
20
82
  const?: string | number | boolean | null;
21
83
  /**
22
- * Oas 3.1 adds support for `contentMediaType` to specify the media type of the content being described by the schema.
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`).
23
86
  */
24
87
  contentMediaType?: string;
25
88
  $ref?: string;
26
89
  };
27
- declare const HttpMethods: {
28
- GET: "get";
29
- POST: "post";
30
- PUT: "put";
31
- PATCH: "patch";
32
- DELETE: "delete";
33
- HEAD: "head";
34
- OPTIONS: "options";
35
- TRACE: "trace";
36
- };
37
- type HttpMethod = HttpMethods$1;
90
+ type HttpMethod = HttpMethods;
38
91
  type Document = OASDocument;
39
92
  type Operation = Operation$1;
40
93
  type DiscriminatorObject = DiscriminatorObject$1;
@@ -106,7 +159,13 @@ type ServerObject = {
106
159
  declare function resolveServerUrl(server: ServerObject, overrides?: Record<string, string>): string;
107
160
  //#endregion
108
161
  //#region src/utils.d.ts
109
- declare function isOpenApiV3_1Document(doc: any): doc is OpenAPIV3_1$1.Document;
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
+ */
110
169
  declare function isParameterObject(obj: ParameterObject | SchemaObject): obj is ParameterObject;
111
170
  /**
112
171
  * Determines if a schema is nullable, considering:
@@ -117,13 +176,14 @@ declare function isNullable(schema?: SchemaObject & {
117
176
  'x-nullable'?: boolean;
118
177
  }): boolean;
119
178
  /**
120
- * Determines if the given object is an OpenAPI ReferenceObject.
179
+ * Returns `true` when `obj` is an OpenAPI `$ref` pointer object.
121
180
  */
122
- declare function isReference(obj?: any): obj is OpenAPIV3$1.ReferenceObject | OpenAPIV3_1$1.ReferenceObject;
181
+ declare function isReference(obj?: unknown): obj is OpenAPIV3$1.ReferenceObject | OpenAPIV3_1$1.ReferenceObject;
123
182
  /**
124
- * Determines if the given object is a SchemaObject with a discriminator property of type DiscriminatorObject.
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).
125
185
  */
126
- declare function isDiscriminator(obj?: any): obj is SchemaObject & {
186
+ declare function isDiscriminator(obj?: unknown): obj is SchemaObject & {
127
187
  discriminator: OpenAPIV3$1.DiscriminatorObject;
128
188
  };
129
189
  /**
@@ -160,10 +220,15 @@ declare function merge(pathOrApi: Array<string | Document>, {
160
220
  oasClass?: typeof Oas;
161
221
  }): Promise<Oas>;
162
222
  declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
223
+ /**
224
+ * Flatten allOf schemas by merging keyword-only fragments.
225
+ * Only flattens schemas where allOf items don't contain structural keys or $refs.
226
+ */
227
+ declare function flattenSchema(schema: SchemaObject | null): SchemaObject | null;
163
228
  /**
164
229
  * Validate an OpenAPI document using oas-normalize.
165
230
  */
166
231
  declare function validate(document: Document): Promise<oas_normalize_lib_types0.ValidationResult>;
167
232
  //#endregion
168
- 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 };
233
+ 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, flattenSchema, getDefaultValue, isAllOptional, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, merge, parse, parseFromConfig, resolveServerUrl, validate };
169
234
  //# sourceMappingURL=index.d.ts.map