@kubb/oas 4.33.5 → 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 +213 -4373
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +82 -22
- package/dist/index.js +208 -4362
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/constants.ts +88 -0
- package/src/index.ts +1 -0
- package/src/parser.ts +1163 -0
- package/src/types.ts +7 -13
- package/src/utils.ts +32 -15
- package/dist/chunk-OuPHjz6n.js +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/oas",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.34.0",
|
|
4
4
|
"description": "OpenAPI Specification (OAS) utilities and helpers for Kubb, providing parsing, normalization, and manipulation of OpenAPI/Swagger schemas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -52,20 +52,25 @@
|
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@kubb/fabric-core": "0.13.3",
|
|
55
56
|
"@redocly/openapi-core": "^2.21.1",
|
|
57
|
+
"@stoplight/yaml": "^4.3.0",
|
|
56
58
|
"jsonpointer": "^5.0.1",
|
|
57
59
|
"oas": "^31.1.2",
|
|
58
60
|
"oas-normalize": "^16.0.2",
|
|
59
61
|
"openapi-types": "^12.1.3",
|
|
60
62
|
"remeda": "^2.33.6",
|
|
61
63
|
"swagger2openapi": "^7.0.8",
|
|
62
|
-
"@kubb/
|
|
64
|
+
"@kubb/ast": "4.34.0",
|
|
65
|
+
"@kubb/core": "4.34.0"
|
|
63
66
|
},
|
|
64
67
|
"devDependencies": {
|
|
65
|
-
"@stoplight/yaml": "^4.3.0",
|
|
66
68
|
"@types/swagger2openapi": "^7.0.4",
|
|
67
69
|
"@internals/utils": "0.0.0"
|
|
68
70
|
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@kubb/fabric-core": "0.13.3"
|
|
73
|
+
},
|
|
69
74
|
"engines": {
|
|
70
75
|
"node": ">=20"
|
|
71
76
|
},
|
|
@@ -75,13 +80,6 @@
|
|
|
75
80
|
},
|
|
76
81
|
"main": "./dist/index.cjs",
|
|
77
82
|
"module": "./dist/index.js",
|
|
78
|
-
"inlinedDependencies": {
|
|
79
|
-
"tslib": "2.8.1",
|
|
80
|
-
"@stoplight/yaml-ast-parser": "0.0.50",
|
|
81
|
-
"@stoplight/yaml": "4.3.0",
|
|
82
|
-
"@stoplight/ordered-object-literal": "1.0.5",
|
|
83
|
-
"@stoplight/types": "14.1.1"
|
|
84
|
-
},
|
|
85
83
|
"scripts": {
|
|
86
84
|
"build": "tsdown && size-limit",
|
|
87
85
|
"clean": "npx rimraf ./dist",
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { MediaType, SchemaType } from '@kubb/ast/types'
|
|
2
|
+
import type { HttpMethods as OASHttpMethods } from 'oas/types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* JSON Schema keywords that indicate structural composition.
|
|
6
|
+
* Used when deciding whether an inline `allOf` fragment can be safely flattened
|
|
7
|
+
* into its parent (fragments containing any of these keys must not be inlined).
|
|
8
|
+
*/
|
|
9
|
+
export const STRUCTURAL_KEYS = new Set<string>(['properties', 'items', 'additionalProperties', 'oneOf', 'anyOf', 'allOf', 'not'])
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Maps OAS/JSON Schema `format` strings to their Kubb `SchemaType` equivalents.
|
|
13
|
+
*
|
|
14
|
+
* Only formats that require a type different from the raw OAS `type` are listed here.
|
|
15
|
+
* `int64`, `date-time`, `date`, and `time` are handled separately because their
|
|
16
|
+
* output depends on runtime parser options and cannot live in a static map.
|
|
17
|
+
*
|
|
18
|
+
* Note: `ipv4`, `ipv6`, and `hostname` map to `'url'` — not semantically accurate,
|
|
19
|
+
* but `'url'` is the closest supported scalar type in the Kubb AST.
|
|
20
|
+
*/
|
|
21
|
+
export const FORMAT_MAP = {
|
|
22
|
+
uuid: 'uuid',
|
|
23
|
+
email: 'email',
|
|
24
|
+
'idn-email': 'email',
|
|
25
|
+
uri: 'url',
|
|
26
|
+
'uri-reference': 'url',
|
|
27
|
+
url: 'url',
|
|
28
|
+
ipv4: 'url',
|
|
29
|
+
ipv6: 'url',
|
|
30
|
+
hostname: 'url',
|
|
31
|
+
'idn-hostname': 'url',
|
|
32
|
+
binary: 'blob',
|
|
33
|
+
byte: 'blob',
|
|
34
|
+
// Numeric formats — format is more specific than type, so these override type.
|
|
35
|
+
// see https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7
|
|
36
|
+
int32: 'integer',
|
|
37
|
+
float: 'number',
|
|
38
|
+
double: 'number',
|
|
39
|
+
} as const satisfies Record<string, SchemaType>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Exhaustive list of media types that Kubb recognizes.
|
|
43
|
+
* Kept as a module-level constant to avoid re-allocating the array on every call.
|
|
44
|
+
*/
|
|
45
|
+
export const KNOWN_MEDIA_TYPES = [
|
|
46
|
+
'application/json',
|
|
47
|
+
'application/xml',
|
|
48
|
+
'application/x-www-form-urlencoded',
|
|
49
|
+
'application/octet-stream',
|
|
50
|
+
'application/pdf',
|
|
51
|
+
'application/zip',
|
|
52
|
+
'application/graphql',
|
|
53
|
+
'multipart/form-data',
|
|
54
|
+
'text/plain',
|
|
55
|
+
'text/html',
|
|
56
|
+
'text/csv',
|
|
57
|
+
'text/xml',
|
|
58
|
+
'image/png',
|
|
59
|
+
'image/jpeg',
|
|
60
|
+
'image/gif',
|
|
61
|
+
'image/webp',
|
|
62
|
+
'image/svg+xml',
|
|
63
|
+
'audio/mpeg',
|
|
64
|
+
'video/mp4',
|
|
65
|
+
] as const satisfies ReadonlyArray<MediaType>
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Vendor extension keys used by various spec generators to attach human-readable
|
|
69
|
+
* labels to enum values. Checked in priority order: the first key found wins.
|
|
70
|
+
*/
|
|
71
|
+
export const ENUM_EXTENSION_KEYS = ['x-enumNames', 'x-enum-varnames'] as const
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Canonical HTTP method names used throughout the Kubb OAS layer.
|
|
75
|
+
* Keys are uppercase (as used in generated code); values are the lowercase
|
|
76
|
+
* strings that the `oas` library uses internally.
|
|
77
|
+
* @deprecated use httpMethods from @kubb/ast
|
|
78
|
+
*/
|
|
79
|
+
export const httpMethods = {
|
|
80
|
+
GET: 'get',
|
|
81
|
+
POST: 'post',
|
|
82
|
+
PUT: 'put',
|
|
83
|
+
PATCH: 'patch',
|
|
84
|
+
DELETE: 'delete',
|
|
85
|
+
HEAD: 'head',
|
|
86
|
+
OPTIONS: 'options',
|
|
87
|
+
TRACE: 'trace',
|
|
88
|
+
} as const satisfies Record<Uppercase<OASHttpMethods>, OASHttpMethods>
|
package/src/index.ts
CHANGED