@kubb/swagger-ts 2.4.0 → 2.4.1

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.
@@ -4,32 +4,32 @@ import { OasTypes } from '@kubb/swagger/oas';
4
4
  import { JSONSchema, FromSchema } from 'json-schema-to-ts';
5
5
  import { TupleToUnion, SplitByDelimiter } from '@kubb/types';
6
6
 
7
- declare namespace Checks$5 {
8
- type AllOFf = {
7
+ type Checks$5 = {
8
+ AllOFf: {
9
9
  allOf: any[];
10
10
  };
11
- type Object = {
11
+ Object: {
12
12
  type: 'object';
13
13
  properties: any;
14
14
  };
15
- type Properties = {
15
+ Properties: {
16
16
  properties: any;
17
17
  };
18
- type PropertiesRequired = {
18
+ PropertiesRequired: {
19
19
  properties: Record<string, any>;
20
20
  required: string[];
21
21
  };
22
- }
23
- type FixAdditionalPropertiesForAllOf<T> = T extends Checks$5.AllOFf ? Omit<T, 'allOf'> & {
22
+ };
23
+ type FixAdditionalPropertiesForAllOf<T> = T extends Checks$5['AllOFf'] ? Omit<T, 'allOf'> & {
24
24
  allOf: Call<Tuples.Map<Objects.Omit<'additionalProperties'>>, T['allOf']>;
25
25
  } : T;
26
- type FixMissingAdditionalProperties<T> = T extends Checks$5.Object ? Omit<T, 'additionalProperties'> & {
26
+ type FixMissingAdditionalProperties<T> = T extends Checks$5['Object'] ? Omit<T, 'additionalProperties'> & {
27
27
  additionalProperties: false;
28
28
  } : T;
29
- type FixMissingTypeObject<T> = T extends Checks$5.Properties ? T & {
29
+ type FixMissingTypeObject<T> = T extends Checks$5['Properties'] ? T & {
30
30
  type: 'object';
31
31
  } : T;
32
- type FixExtraRequiredFields<T> = T extends Checks$5.PropertiesRequired ? Omit<T, 'required'> & {
32
+ type FixExtraRequiredFields<T> = T extends Checks$5['PropertiesRequired'] ? Omit<T, 'required'> & {
33
33
  required: Call<Tuples.Filter<Booleans.Extends<keyof T['properties']>>, T['required']>;
34
34
  } : T;
35
35
  type FixJSONSchema<T> = FixAdditionalPropertiesForAllOf<FixMissingAdditionalProperties<FixMissingTypeObject<FixExtraRequiredFields<T>>>>;
@@ -48,29 +48,29 @@ type ResolveRefsInObj<T, TBase = T> = {
48
48
  };
49
49
  type Infer<TOAS> = Mutable<ResolveRefsInObj<TOAS>>;
50
50
 
51
- declare namespace Checks$4 {
52
- type Required = {
51
+ type Checks$4<TParamType = never> = {
52
+ Required: {
53
53
  required: true;
54
54
  };
55
- type Schemas = {
55
+ Schemas: {
56
56
  schema: JSONSchema;
57
57
  };
58
- type Enum = {
58
+ Enum: {
59
59
  type: JSONSchemaTypeName;
60
60
  enum?: any[];
61
61
  };
62
- type Parameters = {
62
+ Parameters: {
63
63
  in: string;
64
64
  required?: boolean;
65
65
  }[];
66
- type SingleParameter<TParamType> = [{
66
+ SingleParameter: [{
67
67
  in: TParamType;
68
68
  required?: true;
69
69
  }];
70
- type Responses = {
70
+ Responses: {
71
71
  responses: any;
72
72
  };
73
- }
73
+ };
74
74
  type PathMap<TOAS extends OasTypes.OASDocument> = TOAS['paths'];
75
75
  interface ParamPropMap {
76
76
  query: 'query';
@@ -80,94 +80,94 @@ interface ParamPropMap {
80
80
  type JSONSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
81
81
  type ParamObj<TParameter extends {
82
82
  name: string;
83
- }> = TParameter extends Checks$4.Required ? {
84
- [TName in TParameter['name']]: TParameter extends Checks$4.Schemas ? FromSchema<TParameter['schema']> : TParameter extends Checks$4.Enum ? FromSchema<{
83
+ }> = TParameter extends Checks$4['Required'] ? {
84
+ [TName in TParameter['name']]: TParameter extends Checks$4['Schemas'] ? FromSchema<TParameter['schema']> : TParameter extends Checks$4['Enum'] ? FromSchema<{
85
85
  type: TParameter['type'];
86
86
  enum: TParameter['enum'];
87
87
  }> : unknown;
88
88
  } : {
89
- [TName in TParameter['name']]?: TParameter extends Checks$4.Schemas ? FromSchema<TParameter['schema']> : TParameter extends Checks$4.Enum ? FromSchema<{
89
+ [TName in TParameter['name']]?: TParameter extends Checks$4['Schemas'] ? FromSchema<TParameter['schema']> : TParameter extends Checks$4['Enum'] ? FromSchema<{
90
90
  type: TParameter['type'];
91
91
  enum: TParameter['enum'];
92
92
  }> : unknown;
93
93
  };
94
- interface ParamToRequestParam<TParameters extends Checks$4.Parameters> extends Fn {
94
+ interface ParamToRequestParam<TParameters extends Checks$4['Parameters']> extends Fn {
95
95
  return: this['arg0'] extends {
96
96
  name: string;
97
97
  in: infer TParamType;
98
- } ? TParameters extends Checks$4.SingleParameter<TParamType> ? {
98
+ } ? TParameters extends Checks$4<TParamType>['SingleParameter'] ? {
99
99
  [TKey in TParamType extends keyof ParamPropMap ? ParamPropMap[TParamType] : never]: ParamObj<this['arg0']>;
100
100
  } : {
101
101
  [TKey in TParamType extends keyof ParamPropMap ? ParamPropMap[TParamType] : never]?: ParamObj<this['arg0']>;
102
102
  } : {};
103
103
  }
104
- type ParamMap<TParameters extends Checks$4.Parameters> = Pipe<TParameters, [
104
+ type ParamMap<TParameters extends Checks$4['Parameters']> = Pipe<TParameters, [
105
105
  Tuples.Map<ParamToRequestParam<TParameters>>,
106
106
  Tuples.ToIntersection
107
107
  ]>;
108
108
  type MethodMap<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>> = PathMap<TOAS>[TPath];
109
- type StatusMap<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = MethodMap<TOAS, TPath>[TMethod] extends Checks$4.Responses ? MethodMap<TOAS, TPath>[TMethod]['responses'] : never;
109
+ type StatusMap<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = MethodMap<TOAS, TPath>[TMethod] extends Checks$4['Responses'] ? MethodMap<TOAS, TPath>[TMethod]['responses'] : never;
110
110
 
111
- declare namespace Checks$3 {
112
- type ModelWithSchemas = {
111
+ type Checks$3<TName extends string | number | symbol = never> = {
112
+ ModelWithSchemas: {
113
113
  components: {
114
114
  schemas: Record<string, JSONSchema>;
115
115
  };
116
116
  };
117
- type ModelWithSchemasNamed<TName extends string | number | symbol> = {
117
+ ModelWithSchemasNamed: {
118
118
  components: {
119
119
  schemas: {
120
120
  [TModelName in TName]: JSONSchema;
121
121
  };
122
122
  };
123
123
  };
124
- type ModelWithDefinitions = {
124
+ ModelWithDefinitions: {
125
125
  definitions: Record<string, JSONSchema>;
126
126
  };
127
- type ModelWithDefinitionsNamed<TName extends string | number | symbol = never> = {
127
+ ModelWithDefinitionsNamed: {
128
128
  definitions: {
129
129
  [TModelName in TName]: JSONSchema;
130
130
  };
131
131
  };
132
- }
133
- type Model<TOAS extends OasTypes.OASDocument, TName extends TOAS extends Checks$3.ModelWithSchemas ? keyof TOAS['components']['schemas'] : TOAS extends Checks$3.ModelWithDefinitions ? keyof TOAS['definitions'] : never> = TOAS extends Checks$3.ModelWithSchemasNamed<TName> ? FromSchema<TOAS['components']['schemas'][TName]> : TOAS extends Checks$3.ModelWithDefinitionsNamed<TName> ? FromSchema<TOAS['definitions'][TName]> : never;
132
+ };
133
+ type Model<TOAS extends OasTypes.OASDocument, TName extends TOAS extends Checks$3['ModelWithSchemas'] ? keyof TOAS['components']['schemas'] : TOAS extends Checks$3['ModelWithDefinitions'] ? keyof TOAS['definitions'] : never> = TOAS extends Checks$3<TName>['ModelWithSchemasNamed'] ? FromSchema<TOAS['components']['schemas'][TName]> : TOAS extends Checks$3<TName>['ModelWithDefinitionsNamed'] ? FromSchema<TOAS['definitions'][TName]> : never;
134
134
 
135
- declare namespace Checks$2 {
136
- type Security = {
135
+ type Checks$2 = {
136
+ Security: {
137
137
  security: {
138
138
  [key: string]: any;
139
139
  }[];
140
140
  };
141
- namespace AuthParams {
142
- type Basic = {
141
+ AuthParams: {
142
+ Basic: {
143
143
  type: 'http';
144
144
  scheme: 'basic';
145
145
  } | {
146
146
  type: 'basic';
147
147
  };
148
- type Bearer = {
148
+ Bearer: {
149
149
  type: 'http';
150
150
  scheme: 'bearer';
151
151
  } | {
152
152
  type: 'bearer';
153
153
  };
154
- type OAuth2 = {
154
+ OAuth2: {
155
155
  type: 'oauth2';
156
156
  };
157
- type ApiKey = {
157
+ ApiKey: {
158
158
  type: 'apiKey';
159
159
  in: 'header';
160
160
  };
161
- }
162
- namespace AuthName {
163
- type Basic = `basic${string}`;
164
- type Bearer = `bearer${string}`;
165
- type OAuth2 = `oauth${string}`;
166
- }
167
- }
168
- type SecuritySchemeName<T extends Checks$2.Security> = Call<Tuples.Map<Objects.Keys>, T['security']>[number];
161
+ };
162
+ AuthName: {
163
+ Basic: `basic${string}`;
164
+ Bearer: `bearer${string}`;
165
+ OAuth2: `oauth${string}`;
166
+ };
167
+ };
168
+ type SecuritySchemeName<T extends Checks$2['Security']> = Call<Tuples.Map<Objects.Keys>, T['security']>[number];
169
169
  declare namespace AuthParams {
170
- type Basic<TSecurityScheme> = TSecurityScheme extends Checks$2.AuthParams.Basic ? {
170
+ type Basic<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['Basic'] ? {
171
171
  headers: {
172
172
  /**
173
173
  * `Authorization` header is required for basic authentication
@@ -183,7 +183,7 @@ declare namespace AuthParams {
183
183
  Authorization: `Basic ${string}`;
184
184
  };
185
185
  } : {};
186
- type Bearer<TSecurityScheme> = TSecurityScheme extends Checks$2.AuthParams.Bearer ? {
186
+ type Bearer<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['Bearer'] ? {
187
187
  /**
188
188
  * `Authorization` header is required for bearer authentication
189
189
  * @see https://swagger.io/docs/specification/authentication/bearer-authentication/
@@ -200,7 +200,7 @@ declare namespace AuthParams {
200
200
  Authorization: `Bearer ${string}`;
201
201
  };
202
202
  } : {};
203
- type ApiKey<TSecurityScheme> = TSecurityScheme extends Checks$2.AuthParams.ApiKey & {
203
+ type ApiKey<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['ApiKey'] & {
204
204
  name: infer TApiKeyHeaderName;
205
205
  } ? {
206
206
  headers: {
@@ -215,7 +215,7 @@ declare namespace AuthParams {
215
215
  [TQueryName in TApiKeyQueryName extends string ? TApiKeyQueryName : never]: string;
216
216
  };
217
217
  } : {};
218
- type OAuth2<TSecurityScheme> = TSecurityScheme extends Checks$2.AuthParams.OAuth2 ? {
218
+ type OAuth2<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['OAuth2'] ? {
219
219
  /**
220
220
  * `Authorization` header is required for OAuth2.
221
221
  */
@@ -229,7 +229,7 @@ declare namespace AuthParams {
229
229
  } : {};
230
230
  }
231
231
  type OASSecurityParams<TSecurityScheme> = AuthParams.Basic<TSecurityScheme> & AuthParams.Bearer<TSecurityScheme> & AuthParams.ApiKey<TSecurityScheme> & AuthParams.OAuth2<TSecurityScheme>;
232
- type SecurityParamsBySecurityRef<TOAS, TSecurityObj> = TSecurityObj extends Checks$2.Security ? TOAS extends {
232
+ type SecurityParamsBySecurityRef<TOAS, TSecurityObj> = TSecurityObj extends Checks$2['Security'] ? TOAS extends {
233
233
  components: {
234
234
  securitySchemes: {
235
235
  [TSecuritySchemeNameKey in SecuritySchemeName<TSecurityObj> extends string ? SecuritySchemeName<TSecurityObj> : never]: infer TSecurityScheme;
@@ -239,18 +239,18 @@ type SecurityParamsBySecurityRef<TOAS, TSecurityObj> = TSecurityObj extends Chec
239
239
  securityDefinitions: {
240
240
  [TSecuritySchemeNameKey in SecuritySchemeName<TSecurityObj> extends string ? SecuritySchemeName<TSecurityObj> : never]: infer TSecurityScheme;
241
241
  };
242
- } ? OASSecurityParams<TSecurityScheme> : SecuritySchemeName<TSecurityObj> extends Checks$2.AuthName.Basic ? AuthParams.Basic<{
242
+ } ? OASSecurityParams<TSecurityScheme> : SecuritySchemeName<TSecurityObj> extends Checks$2['AuthName']['Basic'] ? AuthParams.Basic<{
243
243
  type: 'http';
244
244
  scheme: 'basic';
245
- }> : SecuritySchemeName<TSecurityObj> extends Checks$2.AuthName.Bearer ? AuthParams.Bearer<{
245
+ }> : SecuritySchemeName<TSecurityObj> extends Checks$2['AuthName']['Bearer'] ? AuthParams.Bearer<{
246
246
  type: 'http';
247
247
  scheme: 'bearer';
248
- }> : SecuritySchemeName<TSecurityObj> extends Checks$2.AuthName.OAuth2 ? AuthParams.OAuth2<{
248
+ }> : SecuritySchemeName<TSecurityObj> extends Checks$2['AuthName']['OAuth2'] ? AuthParams.OAuth2<{
249
249
  type: 'oauth2';
250
250
  }> : {} : {};
251
251
 
252
- declare namespace Checks$1 {
253
- type RequestBodyJson = {
252
+ type Checks$1 = {
253
+ RequestBodyJson: {
254
254
  requestBody: {
255
255
  content: {
256
256
  'application/json': {
@@ -259,7 +259,7 @@ declare namespace Checks$1 {
259
259
  };
260
260
  };
261
261
  };
262
- type RequestBodyFormData = {
262
+ RequestBodyFormData: {
263
263
  requestBody: {
264
264
  content: {
265
265
  'multipart/form-data': {
@@ -268,7 +268,7 @@ declare namespace Checks$1 {
268
268
  };
269
269
  };
270
270
  };
271
- type RequestBodyFormEncoded = {
271
+ RequestBodyFormEncoded: {
272
272
  requestBody: {
273
273
  content: {
274
274
  'application/x-www-form-urlencoded': {
@@ -277,18 +277,18 @@ declare namespace Checks$1 {
277
277
  };
278
278
  };
279
279
  };
280
- type Parameters = {
280
+ Parameters: {
281
281
  parameters: {
282
282
  name: string;
283
283
  in: string;
284
284
  }[];
285
285
  };
286
- type PathBrackets = `${string}{${string}}${string}`;
287
- type PathPattern = `${string}:${string}${string}`;
288
- type Required = {
286
+ PathBrackets: `${string}{${string}}${string}`;
287
+ PathPattern: `${string}:${string}${string}`;
288
+ Required: {
289
289
  required: true;
290
290
  };
291
- }
291
+ };
292
292
  type ExtractPathParamsWithPattern<TPath extends string> = Pipe<TPath, [
293
293
  Strings.Split<'/'>,
294
294
  Tuples.Filter<Strings.StartsWith<':'>>,
@@ -304,7 +304,7 @@ type ExtractSubSegments<T extends any[]> = {
304
304
  [K in keyof T]: SplitByDelimiter<T[K], ';'>;
305
305
  };
306
306
  type ExtractPathParamsWithBrackets<TPath extends string> = TupleToUnion<ExtractPathParameters<ExtractSubSegments<ExtractSegments<TPath>>[number]>>;
307
- type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = (MethodMap<TOAS, TPath>[TMethod] extends Checks$1.RequestBodyJson ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1.Required ? {
307
+ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = (MethodMap<TOAS, TPath>[TMethod] extends Checks$1['RequestBodyJson'] ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1['Required'] ? {
308
308
  /**
309
309
  * The request body in JSON is required for this request.
310
310
  *
@@ -318,7 +318,7 @@ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMa
318
318
  * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
319
319
  */
320
320
  json?: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']>;
321
- } : MethodMap<TOAS, TPath>[TMethod] extends Checks$1.RequestBodyFormData ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1.Required ? {
321
+ } : MethodMap<TOAS, TPath>[TMethod] extends Checks$1['RequestBodyFormData'] ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1['Required'] ? {
322
322
  /**
323
323
  * The request body in multipart/form-data is required for this request.
324
324
  *
@@ -332,7 +332,7 @@ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMa
332
332
  * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
333
333
  */
334
334
  formData?: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['multipart/form-data']['schema']>;
335
- } : MethodMap<TOAS, TPath>[TMethod] extends Checks$1.RequestBodyFormEncoded ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1.Required ? {
335
+ } : MethodMap<TOAS, TPath>[TMethod] extends Checks$1['RequestBodyFormEncoded'] ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1['Required'] ? {
336
336
  /**
337
337
  * The request body in application/x-www-form-urlencoded is required for this request.
338
338
  *
@@ -346,8 +346,8 @@ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMa
346
346
  * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
347
347
  */
348
348
  formUrlEncoded?: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']>;
349
- } : {}) & (MethodMap<TOAS, TPath>[TMethod] extends Checks$1.Parameters ? ParamMap<MethodMap<TOAS, TPath>[TMethod]['parameters']> : {}) & // If there is any parameters defined in path but not in the parameters array, we should add them to the params
350
- (TPath extends Checks$1.PathBrackets ? {
349
+ } : {}) & (MethodMap<TOAS, TPath>[TMethod] extends Checks$1['Parameters'] ? ParamMap<MethodMap<TOAS, TPath>[TMethod]['parameters']> : {}) & // If there is any parameters defined in path but not in the parameters array, we should add them to the params
350
+ (TPath extends Checks$1['PathBrackets'] ? {
351
351
  /**
352
352
  * Parameters defined in the path are required for this request.
353
353
  *
@@ -356,7 +356,7 @@ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMa
356
356
  * For example if path is `/todos/{id}` and `params` is `{ id: '1' }`, the path will be `/todos/1`
357
357
  */
358
358
  params: Record<ExtractPathParamsWithBrackets<TPath>, string | number | bigint | boolean>;
359
- } : {}) & (TPath extends Checks$1.PathPattern ? {
359
+ } : {}) & (TPath extends Checks$1['PathPattern'] ? {
360
360
  /**
361
361
  * Parameters defined in the path are required for this request.
362
362
  *
@@ -369,18 +369,18 @@ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMa
369
369
  SecurityParamsBySecurityRef<TOAS, MethodMap<TOAS, TPath>[TMethod]> & // Respect global security definitions
370
370
  SecurityParamsBySecurityRef<TOAS, TOAS>;
371
371
 
372
- declare namespace Checks {
373
- type Content = {
372
+ type Checks = {
373
+ Content: {
374
374
  content: any;
375
375
  };
376
- }
376
+ };
377
377
  type ResponseSchemas<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatus extends keyof StatusMap<TOAS, TPath, TMethod>> = StatusMap<TOAS, TPath, TMethod>[TStatus]['content'];
378
- type JSONResponseSchema<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatus extends keyof StatusMap<TOAS, TPath, TMethod>> = StatusMap<TOAS, TPath, TMethod>[TStatus] extends Checks.Content ? ResponseSchemas<TOAS, TPath, TMethod, TStatus>[keyof ResponseSchemas<TOAS, TPath, TMethod, TStatus>]['schema'] : StatusMap<TOAS, TPath, TMethod>[TStatus]['schema'];
378
+ type JSONResponseSchema<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatus extends keyof StatusMap<TOAS, TPath, TMethod>> = StatusMap<TOAS, TPath, TMethod>[TStatus] extends Checks['Content'] ? ResponseSchemas<TOAS, TPath, TMethod, TStatus>[keyof ResponseSchemas<TOAS, TPath, TMethod, TStatus>]['schema'] : StatusMap<TOAS, TPath, TMethod>[TStatus]['schema'];
379
379
  type Response<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatusCode extends keyof StatusMap<TOAS, TPath, TMethod> = 200> = FromSchema<JSONResponseSchema<TOAS, TPath, TMethod, TStatusCode>>;
380
380
 
381
381
  type index_Infer<TOAS> = Infer<TOAS>;
382
382
  type index_MethodMap<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>> = MethodMap<TOAS, TPath>;
383
- type index_Model<TOAS extends OasTypes.OASDocument, TName extends TOAS extends Checks$3.ModelWithSchemas ? keyof TOAS['components']['schemas'] : TOAS extends Checks$3.ModelWithDefinitions ? keyof TOAS['definitions'] : never> = Model<TOAS, TName>;
383
+ type index_Model<TOAS extends OasTypes.OASDocument, TName extends TOAS extends Checks$3['ModelWithSchemas'] ? keyof TOAS['components']['schemas'] : TOAS extends Checks$3['ModelWithDefinitions'] ? keyof TOAS['definitions'] : never> = Model<TOAS, TName>;
384
384
  type index_PathMap<TOAS extends OasTypes.OASDocument> = PathMap<TOAS>;
385
385
  type index_RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = RequestParams<TOAS, TPath, TMethod>;
386
386
  type index_Response<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatusCode extends keyof StatusMap<TOAS, TPath, TMethod> = 200> = Response<TOAS, TPath, TMethod, TStatusCode>;
package/dist/index.cjs CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var chunkFUVECZEQ_cjs = require('./chunk-FUVECZEQ.cjs');
5
+ var chunkCMZLMWOU_cjs = require('./chunk-CMZLMWOU.cjs');
6
6
 
7
7
  // src/index.ts
8
- var src_default = chunkFUVECZEQ_cjs.definePlugin;
8
+ var src_default = chunkCMZLMWOU_cjs.definePlugin;
9
9
 
10
10
  Object.defineProperty(exports, "definePlugin", {
11
11
  enumerable: true,
12
- get: function () { return chunkFUVECZEQ_cjs.definePlugin; }
12
+ get: function () { return chunkCMZLMWOU_cjs.definePlugin; }
13
13
  });
14
14
  Object.defineProperty(exports, "pluginKey", {
15
15
  enumerable: true,
16
- get: function () { return chunkFUVECZEQ_cjs.pluginKey; }
16
+ get: function () { return chunkCMZLMWOU_cjs.pluginKey; }
17
17
  });
18
18
  Object.defineProperty(exports, "pluginName", {
19
19
  enumerable: true,
20
- get: function () { return chunkFUVECZEQ_cjs.pluginName; }
20
+ get: function () { return chunkCMZLMWOU_cjs.pluginName; }
21
21
  });
22
22
  exports.default = src_default;
23
23
  //# sourceMappingURL=out.js.map
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
2
  import { P as PluginOptions, O as Options } from './types-ZlpJhb2p.cjs';
3
3
  export { F as FileMeta } from './types-ZlpJhb2p.cjs';
4
- export { i as Oas } from './index-sycg8owy.cjs';
4
+ export { i as Oas } from './index-x0xIwSiH.cjs';
5
5
  import '@kubb/swagger';
6
6
  import 'hotscript';
7
7
  import 'ts-toolbelt';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
2
  import { P as PluginOptions, O as Options } from './types-ZlpJhb2p.js';
3
3
  export { F as FileMeta } from './types-ZlpJhb2p.js';
4
- export { i as Oas } from './index-sycg8owy.js';
4
+ export { i as Oas } from './index-x0xIwSiH.js';
5
5
  import '@kubb/swagger';
6
6
  import 'hotscript';
7
7
  import 'ts-toolbelt';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { definePlugin } from './chunk-FCNKYMOH.js';
2
- export { definePlugin, pluginKey, pluginName } from './chunk-FCNKYMOH.js';
1
+ import { definePlugin } from './chunk-7UWJRVRW.js';
2
+ export { definePlugin, pluginKey, pluginName } from './chunk-7UWJRVRW.js';
3
3
 
4
4
  // src/index.ts
5
5
  var src_default = definePlugin;
package/dist/oas.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { I as Infer, M as MethodMap, a as Model, P as PathMap, R as RequestParams, b as Response, S as StatusMap } from './index-sycg8owy.cjs';
1
+ export { I as Infer, M as MethodMap, a as Model, P as PathMap, R as RequestParams, b as Response, S as StatusMap } from './index-x0xIwSiH.cjs';
2
2
  import 'hotscript';
3
3
  import 'ts-toolbelt';
4
4
  import '@kubb/swagger/oas';
package/dist/oas.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { I as Infer, M as MethodMap, a as Model, P as PathMap, R as RequestParams, b as Response, S as StatusMap } from './index-sycg8owy.js';
1
+ export { I as Infer, M as MethodMap, a as Model, P as PathMap, R as RequestParams, b as Response, S as StatusMap } from './index-x0xIwSiH.js';
2
2
  import 'hotscript';
3
3
  import 'ts-toolbelt';
4
4
  import '@kubb/swagger/oas';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/swagger-ts",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Generator swagger-ts",
5
5
  "keywords": [
6
6
  "typescript",
@@ -49,11 +49,11 @@
49
49
  "hotscript": "^1.0.13",
50
50
  "json-schema-to-ts": "^3.0.0",
51
51
  "ts-toolbelt": "^9.6.0",
52
- "@kubb/core": "2.4.0",
53
- "@kubb/parser": "2.4.0",
54
- "@kubb/swagger": "2.4.0",
55
- "@kubb/types": "2.4.0",
56
- "@kubb/react": "2.4.0"
52
+ "@kubb/core": "2.4.1",
53
+ "@kubb/parser": "2.4.1",
54
+ "@kubb/swagger": "2.4.1",
55
+ "@kubb/types": "2.4.1",
56
+ "@kubb/react": "2.4.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react": "^18.2.48",
@@ -62,11 +62,11 @@
62
62
  "react": "^18.2.0",
63
63
  "tsup": "^8.0.1",
64
64
  "@kubb/eslint-config": "1.1.8",
65
- "@kubb/tsup-config": "1.1.8",
66
- "@kubb/ts-config": "0.1.0"
65
+ "@kubb/ts-config": "0.1.0",
66
+ "@kubb/tsup-config": "1.1.8"
67
67
  },
68
68
  "peerDependencies": {
69
- "@kubb/react": "2.4.0"
69
+ "@kubb/react": "2.4.1"
70
70
  },
71
71
  "packageManager": "pnpm@8.3.0",
72
72
  "engines": {
@@ -174,7 +174,8 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
174
174
  originalName,
175
175
  }
176
176
 
177
- const path = this.context.pluginManager.resolvePath({ baseName: propertyName, pluginKey })
177
+ const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })
178
+ const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })
178
179
 
179
180
  this.imports.push({
180
181
  ref,
@@ -64,19 +64,24 @@ function printCombinedSchema(name: string, operation: Operation, schemas: Operat
64
64
  })!
65
65
  }
66
66
 
67
- const namespaceNode = factory.createNamespaceDeclaration({
67
+ const namespaceNode = factory.createTypeAliasDeclaration({
68
68
  name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,
69
- statements: Object.keys(properties).map(key => {
70
- const type = properties[key]
71
- if (!type) {
72
- return undefined
73
- }
74
- return factory.createTypeAliasDeclaration({
75
- modifiers: [factory.modifiers.export],
76
- name: transformers.pascalCase(key),
77
- type,
78
- })
79
- }).filter(Boolean),
69
+ type: factory.createTypeLiteralNode(
70
+ Object.keys(properties).map(key => {
71
+ const type = properties[key]
72
+ if (!type) {
73
+ return undefined
74
+ }
75
+
76
+ return factory.createPropertySignature(
77
+ {
78
+ name: transformers.pascalCase(key),
79
+ type,
80
+ },
81
+ )
82
+ }).filter(Boolean),
83
+ ),
84
+ modifiers: [factory.modifiers.export],
80
85
  })
81
86
 
82
87
  return print(namespaceNode)
package/src/oas/infer.ts CHANGED
@@ -1,30 +1,29 @@
1
- /* eslint-disable @typescript-eslint/no-namespace */
2
1
  import type { Booleans, Call, Objects, Strings, Tuples } from 'hotscript'
3
2
  import type { Object } from 'ts-toolbelt'
4
3
 
5
- namespace Checks {
6
- export type AllOFf = { allOf: any[] }
7
- export type Object = {
4
+ type Checks = {
5
+ AllOFf: { allOf: any[] }
6
+ Object: {
8
7
  type: 'object'
9
8
  properties: any
10
9
  }
11
- export type Properties = { properties: any }
12
- export type PropertiesRequired = {
10
+ Properties: { properties: any }
11
+ PropertiesRequired: {
13
12
  properties: Record<string, any>
14
13
  required: string[]
15
14
  }
16
15
  }
17
16
 
18
- type FixAdditionalPropertiesForAllOf<T> = T extends Checks.AllOFf ? Omit<T, 'allOf'> & {
17
+ type FixAdditionalPropertiesForAllOf<T> = T extends Checks['AllOFf'] ? Omit<T, 'allOf'> & {
19
18
  allOf: Call<Tuples.Map<Objects.Omit<'additionalProperties'>>, T['allOf']>
20
19
  }
21
20
  : T
22
21
 
23
- type FixMissingAdditionalProperties<T> = T extends Checks.Object ? Omit<T, 'additionalProperties'> & { additionalProperties: false }
22
+ type FixMissingAdditionalProperties<T> = T extends Checks['Object'] ? Omit<T, 'additionalProperties'> & { additionalProperties: false }
24
23
  : T
25
- type FixMissingTypeObject<T> = T extends Checks.Properties ? T & { type: 'object' } : T
24
+ type FixMissingTypeObject<T> = T extends Checks['Properties'] ? T & { type: 'object' } : T
26
25
 
27
- type FixExtraRequiredFields<T> = T extends Checks.PropertiesRequired ? Omit<T, 'required'> & {
26
+ type FixExtraRequiredFields<T> = T extends Checks['PropertiesRequired'] ? Omit<T, 'required'> & {
28
27
  required: Call<Tuples.Filter<Booleans.Extends<keyof T['properties']>>, T['required']>
29
28
  }
30
29
  : T