@kubb/oas 4.28.1 → 4.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/oas",
3
- "version": "4.28.1",
3
+ "version": "4.29.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",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "https://github.com/kubb-labs/kubb.git",
22
+ "url": "git+https://github.com/kubb-labs/kubb.git",
23
23
  "directory": "packages/oas"
24
24
  },
25
25
  "license": "MIT",
@@ -28,14 +28,12 @@
28
28
  "type": "module",
29
29
  "exports": {
30
30
  ".": {
31
- "require": "./dist/index.cjs",
32
- "import": "./dist/index.js"
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
33
  },
34
34
  "./package.json": "./package.json"
35
35
  },
36
- "main": "./dist/index.cjs",
37
- "module": "./dist/index.js",
38
- "types": "./dist/index.d.cts",
36
+ "types": "./dist/index.d.ts",
39
37
  "typesVersions": {
40
38
  "*": {}
41
39
  },
@@ -60,7 +58,7 @@
60
58
  "openapi-types": "^12.1.3",
61
59
  "remeda": "^2.33.6",
62
60
  "swagger2openapi": "^7.0.8",
63
- "@kubb/core": "4.28.1"
61
+ "@kubb/core": "4.29.0"
64
62
  },
65
63
  "devDependencies": {
66
64
  "@stoplight/yaml": "^4.3.0",
@@ -73,6 +71,8 @@
73
71
  "access": "public",
74
72
  "registry": "https://registry.npmjs.org/"
75
73
  },
74
+ "main": "./dist/index.cjs",
75
+ "module": "./dist/index.js",
76
76
  "scripts": {
77
77
  "build": "tsdown && size-limit",
78
78
  "clean": "npx rimraf ./dist",
package/src/Oas.ts CHANGED
@@ -67,7 +67,7 @@ export class Oas extends BaseOas {
67
67
  if (!current) {
68
68
  throw new Error(`Could not find a definition for ${origRef}.`)
69
69
  }
70
- return current
70
+ return current as T
71
71
  }
72
72
 
73
73
  getKey($ref: string) {
package/dist/index.d.cts DELETED
@@ -1,135 +0,0 @@
1
- import * as _readme_openapi_parser0 from "@readme/openapi-parser";
2
- import BaseOas from "oas";
3
- import { Operation as Operation$1 } from "oas/operation";
4
- import * as OasTypes from "oas/types";
5
- 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";
6
- import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1, OpenAPIV3_1 as OpenAPIV3_1$1 } from "openapi-types";
7
- import { Config } from "@kubb/core";
8
-
9
- //#region rolldown:runtime
10
- //#endregion
11
- //#region src/types.d.ts
12
- type contentType = 'application/json' | (string & {});
13
- type SchemaObject = SchemaObject$1 & {
14
- 'x-nullable'?: boolean;
15
- $ref?: string;
16
- };
17
- declare const HttpMethods: {
18
- GET: "get";
19
- POST: "post";
20
- PUT: "put";
21
- PATCH: "patch";
22
- DELETE: "delete";
23
- HEAD: "head";
24
- OPTIONS: "options";
25
- TRACE: "trace";
26
- };
27
- type HttpMethod = HttpMethods$1;
28
- type Document = OASDocument;
29
- type Operation = Operation$1;
30
- type DiscriminatorObject = DiscriminatorObject$1;
31
- type ReferenceObject = OpenAPIV3$1.ReferenceObject;
32
- type ResponseObject = ResponseObject$1;
33
- type MediaTypeObject = MediaTypeObject$1;
34
- //#endregion
35
- //#region src/Oas.d.ts
36
- type OasOptions = {
37
- contentType?: contentType;
38
- discriminator?: 'strict' | 'inherit';
39
- /**
40
- * Resolve name collisions when schemas from different components share the same name (case-insensitive).
41
- * @default false
42
- */
43
- collisionDetection?: boolean;
44
- };
45
- declare class Oas extends BaseOas {
46
- #private;
47
- document: Document;
48
- constructor(document: Document);
49
- setOptions(options: OasOptions): void;
50
- get options(): OasOptions;
51
- get<T = unknown>($ref: string): T | null;
52
- getKey($ref: string): string | undefined;
53
- set($ref: string, value: unknown): false | undefined;
54
- getDiscriminator(schema: SchemaObject | null): DiscriminatorObject | null;
55
- dereferenceWithRef<T = unknown>(schema?: T): T;
56
- getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
57
- getRequestSchema(operation: Operation): SchemaObject | undefined;
58
- getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
59
- validate(): Promise<_readme_openapi_parser0.ValidationResult>;
60
- flattenSchema(schema: SchemaObject | null): SchemaObject | null;
61
- /**
62
- * Get schemas from OpenAPI components (schemas, responses, requestBodies).
63
- * Returns schemas in dependency order along with name mapping for collision resolution.
64
- */
65
- getSchemas(options?: {
66
- contentType?: contentType;
67
- includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
68
- collisionDetection?: boolean;
69
- }): {
70
- schemas: Record<string, SchemaObject>;
71
- nameMapping: Map<string, string>;
72
- };
73
- }
74
- //#endregion
75
- //#region src/utils.d.ts
76
- declare function isOpenApiV3_1Document(doc: any): doc is OpenAPIV3_1$1.Document;
77
- declare function isParameterObject(obj: ParameterObject | SchemaObject$1): obj is ParameterObject;
78
- /**
79
- * Determines if a schema is nullable, considering:
80
- * - OpenAPI 3.0 `nullable` / `x-nullable`
81
- * - OpenAPI 3.1 JSON Schema `type: ['null', ...]` or `type: 'null'`
82
- */
83
- declare function isNullable(schema?: SchemaObject$1 & {
84
- 'x-nullable'?: boolean;
85
- }): boolean;
86
- /**
87
- * Determines if the given object is an OpenAPI ReferenceObject.
88
- */
89
- declare function isReference(obj?: any): obj is OpenAPIV3$1.ReferenceObject | OpenAPIV3_1$1.ReferenceObject;
90
- /**
91
- * Determines if the given object is a SchemaObject with a discriminator property of type DiscriminatorObject.
92
- */
93
- declare function isDiscriminator(obj?: any): obj is SchemaObject$1 & {
94
- discriminator: OpenAPIV3$1.DiscriminatorObject;
95
- };
96
- /**
97
- * Determines whether a schema is required.
98
- *
99
- * Returns true if the schema has a non-empty {@link SchemaObject.required} array or a truthy {@link SchemaObject.required} property.
100
- */
101
- declare function isRequired(schema?: SchemaObject$1): boolean;
102
- declare function isAllOptional(schema: unknown): boolean;
103
- declare function isOptional(schema?: SchemaObject$1): boolean;
104
- /**
105
- * Determines the appropriate default value for a schema parameter.
106
- * - For array types: returns '[]'
107
- * - For union types (anyOf/oneOf):
108
- * - If at least one variant has all-optional fields: returns '{}'
109
- * - Otherwise: returns undefined (no default)
110
- * - For object types with optional fields: returns '{}'
111
- * - For primitive types (string, number, boolean): returns undefined (no default)
112
- * - For required types: returns undefined (no default)
113
- */
114
- declare function getDefaultValue(schema?: SchemaObject$1): string | undefined;
115
- declare function parse(pathOrApi: string | Document, {
116
- oasClass,
117
- enablePaths
118
- }?: {
119
- oasClass?: typeof Oas;
120
- canBundle?: boolean;
121
- enablePaths?: boolean;
122
- }): Promise<Oas>;
123
- declare function merge(pathOrApi: Array<string | Document>, {
124
- oasClass
125
- }?: {
126
- oasClass?: typeof Oas;
127
- }): Promise<Oas>;
128
- declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
129
- /**
130
- * Validate an OpenAPI document using oas-normalize.
131
- */
132
- declare function validate(document: Document): Promise<_readme_openapi_parser0.ValidationResult>;
133
- //#endregion
134
- export { DiscriminatorObject, Document, HttpMethod, HttpMethods, 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, validate };
135
- //# sourceMappingURL=index.d.cts.map