@kubb/swagger-ts 2.7.1 → 2.8.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.
@@ -1,5 +1,5 @@
1
1
  import { Generator } from '@kubb/core'
2
- import transformers from '@kubb/core/transformers'
2
+ import transformers, { pascalCase } from '@kubb/core/transformers'
3
3
  import { getUniqueName } from '@kubb/core/utils'
4
4
  import * as factory from '@kubb/parser/factory'
5
5
  import { keywordTypeNodes } from '@kubb/parser/factory'
@@ -10,7 +10,7 @@ import { pluginKey } from './plugin.ts'
10
10
  import type { PluginManager } from '@kubb/core'
11
11
  import type { ts } from '@kubb/parser'
12
12
  import type { ImportMeta, Refs } from '@kubb/swagger'
13
- import type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'
13
+ import type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/swagger/oas'
14
14
  import type { PluginOptions } from './types.ts'
15
15
 
16
16
  // based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398
@@ -38,7 +38,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
38
38
  description,
39
39
  keysToOmit,
40
40
  }: {
41
- schema: OasTypes.SchemaObject
41
+ schema: SchemaObject
42
42
  baseName: string
43
43
  description?: string
44
44
  optional?: boolean
@@ -88,31 +88,33 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
88
88
  * Delegates to getBaseTypeFromSchema internally and
89
89
  * optionally adds a union with null.
90
90
  */
91
- getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {
91
+ getTypeFromSchema(schema?: SchemaObject, name?: string): ts.TypeNode | null {
92
92
  const type = this.#getBaseTypeFromSchema(schema, name)
93
93
 
94
94
  if (!type) {
95
95
  return null
96
96
  }
97
97
 
98
- if (schema && !schema.nullable) {
99
- return type
98
+ const nullable = (schema?.nullable ?? schema?.['x-nullable']) ?? false
99
+
100
+ if (nullable) {
101
+ return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })
100
102
  }
101
103
 
102
- return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })
104
+ return type
103
105
  }
104
106
 
105
107
  /**
106
108
  * Recursively creates a type literal with the given props.
107
109
  */
108
- #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {
110
+ #getTypeFromProperties(baseSchema?: SchemaObject, baseName?: string): ts.TypeNode | null {
109
111
  const { optionalType } = this.options
110
112
  const properties = baseSchema?.properties || {}
111
113
  const required = baseSchema?.required
112
114
  const additionalProperties = baseSchema?.additionalProperties
113
115
 
114
116
  const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {
115
- const schema = properties[name] as OasTypes.SchemaObject
117
+ const schema = properties[name] as SchemaObject
116
118
 
117
119
  const isRequired = Array.isArray(required) ? required.includes(name) : !!required
118
120
  let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))
@@ -144,7 +146,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
144
146
  })
145
147
  })
146
148
  if (additionalProperties) {
147
- const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)
149
+ const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as SchemaObject)
148
150
 
149
151
  if (type) {
150
152
  members.push(factory.createIndexSignature(type))
@@ -184,7 +186,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
184
186
  return factory.createTypeReferenceNode(ref.propertyName, undefined)
185
187
  }
186
188
 
187
- #getParsedSchema(schema?: OasTypes.SchemaObject) {
189
+ #getParsedSchema(schema?: SchemaObject) {
188
190
  const parsedSchema = getSchemaFactory(this.context.oas)(schema)
189
191
  return parsedSchema
190
192
  }
@@ -194,7 +196,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
194
196
  * schema and returns the appropriate type.
195
197
  */
196
198
  #getBaseTypeFromSchema(
197
- _schema: OasTypes.SchemaObject | undefined,
199
+ _schema: SchemaObject | undefined,
198
200
  baseName?: string,
199
201
  ): ts.TypeNode | null {
200
202
  const { schema, version } = this.#getParsedSchema(_schema)
@@ -209,13 +211,13 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
209
211
 
210
212
  if (schema.oneOf) {
211
213
  // union
212
- const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject
214
+ const schemaWithoutOneOf = { ...schema, oneOf: undefined } as SchemaObject
213
215
 
214
216
  const union = factory.createUnionDeclaration({
215
217
  withParentheses: true,
216
218
  nodes: schema.oneOf
217
219
  .map((item) => {
218
- return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)
220
+ return item && this.getTypeFromSchema(item as SchemaObject)
219
221
  })
220
222
  .filter((item) => {
221
223
  return item && item !== this.#unknownReturn
@@ -232,13 +234,13 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
232
234
  }
233
235
 
234
236
  if (schema.anyOf) {
235
- const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject
237
+ const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as SchemaObject
236
238
 
237
239
  const union = factory.createUnionDeclaration({
238
240
  withParentheses: true,
239
241
  nodes: schema.anyOf
240
242
  .map((item) => {
241
- return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)
243
+ return item && this.getTypeFromSchema(item as SchemaObject)
242
244
  })
243
245
  .filter((item) => {
244
246
  return item && item !== this.#unknownReturn
@@ -255,13 +257,13 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
255
257
  }
256
258
  if (schema.allOf) {
257
259
  // intersection/add
258
- const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject
260
+ const schemaWithoutAllOf = { ...schema, allOf: undefined } as SchemaObject
259
261
 
260
262
  const and = factory.createIntersectionDeclaration({
261
263
  withParentheses: true,
262
264
  nodes: schema.allOf
263
265
  .map((item) => {
264
- return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)
266
+ return item && this.getTypeFromSchema(item as SchemaObject)
265
267
  })
266
268
  .filter((item) => {
267
269
  return item && item !== this.#unknownReturn
@@ -281,7 +283,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
281
283
  * Enum will be defined outside the baseType(hints the baseName check)
282
284
  */
283
285
  if (schema.enum && baseName) {
284
- const enumName = getUniqueName(baseName, this.options.usedEnumNames)
286
+ const enumName = getUniqueName(pascalCase([baseName, this.options.enumSuffix].join(' ')), this.options.usedEnumNames)
285
287
 
286
288
  let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])
287
289
 
@@ -316,7 +318,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
316
318
 
317
319
  if ('items' in schema) {
318
320
  // items -> array
319
- const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)
321
+ const node = this.getTypeFromSchema(schema.items as SchemaObject, baseName)
320
322
  if (node) {
321
323
  return factory.createArrayTypeNode(node)
322
324
  }
@@ -328,7 +330,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
328
330
  */
329
331
 
330
332
  if ('prefixItems' in schema) {
331
- const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]
333
+ const prefixItems = schema.prefixItems as SchemaObject[]
332
334
 
333
335
  return factory.createTupleDeclaration({
334
336
  nodes: prefixItems.map((item) => {
@@ -340,7 +342,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
340
342
 
341
343
  if (schema.properties || schema.additionalProperties) {
342
344
  // properties -> literal type
343
- return this.#getTypeFromProperties(schema, baseName)
345
+ return this.#getTypeFromProperties(schema as SchemaObject, baseName)
344
346
  }
345
347
 
346
348
  /**
@@ -378,7 +380,7 @@ export class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], C
378
380
  {
379
381
  ...schema,
380
382
  type,
381
- },
383
+ } as SchemaObject,
382
384
  baseName,
383
385
  ),
384
386
  nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,
@@ -107,7 +107,7 @@ Mutation.File = function({ mode }: FileProps): ReactNode {
107
107
 
108
108
  const schemas = useSchemas()
109
109
  const pluginManager = usePluginManager()
110
- const oas = useOas()
110
+ const { oas } = useOas()
111
111
  const file = useOperationFile()
112
112
  const factoryName = useOperationName({ type: 'type' })
113
113
  const operation = useOperation()
@@ -42,12 +42,12 @@ type Props = {
42
42
  Template?: React.ComponentType<React.ComponentProps<typeof Template>>
43
43
  }
44
44
 
45
- export function Oas({
45
+ export function OasType({
46
46
  name,
47
47
  typeName,
48
48
  Template = defaultTemplates.default,
49
49
  }: Props): ReactNode {
50
- const oas = useOas()
50
+ const { oas } = useOas()
51
51
 
52
52
  return <Template name={name} typeName={typeName} api={oas.api} />
53
53
  }
@@ -61,7 +61,7 @@ type FileProps = {
61
61
  templates?: typeof defaultTemplates
62
62
  }
63
63
 
64
- Oas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {
64
+ OasType.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {
65
65
  const { key: pluginKey } = usePlugin<PluginOptions>()
66
66
  const file = useFile({ name, extName: '.ts', pluginKey })
67
67
 
@@ -76,11 +76,11 @@ Oas.File = function({ name, typeName, templates = defaultTemplates }: FileProps)
76
76
  >
77
77
  <File.Import name={['Infer']} path="@kubb/swagger-ts/oas" isTypeOnly />
78
78
  <File.Source>
79
- <Oas Template={Template} name={name} typeName={typeName} />
79
+ <OasType Template={Template} name={name} typeName={typeName} />
80
80
  </File.Source>
81
81
  </File>
82
82
  </Editor>
83
83
  )
84
84
  }
85
85
 
86
- Oas.templates = defaultTemplates
86
+ OasType.templates = defaultTemplates
@@ -108,7 +108,7 @@ Query.File = function({ mode }: FileProps): ReactNode {
108
108
 
109
109
  const schemas = useSchemas()
110
110
  const pluginManager = usePluginManager()
111
- const oas = useOas()
111
+ const { oas } = useOas()
112
112
  const file = useOperationFile()
113
113
  const factoryName = useOperationName({ type: 'type' })
114
114
  const operation = useOperation()
@@ -1,3 +1,3 @@
1
1
  export { Mutation } from './Mutation.tsx'
2
- export { Oas } from './Oas.tsx'
2
+ export { OasType } from './OasType.tsx'
3
3
  export { Query } from './Query.tsx'
package/src/plugin.ts CHANGED
@@ -23,6 +23,7 @@ export const definePlugin = createPlugin<PluginOptions>((options) => {
23
23
  include,
24
24
  override = [],
25
25
  enumType = 'asConst',
26
+ enumSuffix = '',
26
27
  dateType = 'string',
27
28
  unknownType = 'any',
28
29
  optionalType = 'questionToken',
@@ -37,6 +38,7 @@ export const definePlugin = createPlugin<PluginOptions>((options) => {
37
38
  transformers,
38
39
  dateType,
39
40
  enumType,
41
+ enumSuffix,
40
42
  optionalType,
41
43
  oasType,
42
44
  // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)
@@ -44,9 +46,9 @@ export const definePlugin = createPlugin<PluginOptions>((options) => {
44
46
  unknownType,
45
47
  },
46
48
  pre: [swaggerPluginName],
47
- resolvePath(baseName, directory, options) {
49
+ resolvePath(baseName, pathMode, options) {
48
50
  const root = path.resolve(this.config.root, this.config.output.path)
49
- const mode = FileManager.getMode(path.resolve(root, output.path))
51
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
50
52
 
51
53
  if (mode === 'file') {
52
54
  /**
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { KubbFile, Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import type { AppMeta as SwaggerAppMeta, Exclude, Include, Override, ResolvePathOptions } from '@kubb/swagger'
2
+ import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/swagger'
3
3
 
4
4
  export type Options = {
5
5
  output?: {
@@ -57,6 +57,13 @@ export type Options = {
57
57
  * @default 'asConst'
58
58
  */
59
59
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
60
+ /**
61
+ * Set a suffix for the generated enums.
62
+ * @default ''
63
+ * Default will be `'enum'` in version 3 of Kubb
64
+ */
65
+ enumSuffix?: string
66
+
60
67
  /**
61
68
  * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
62
69
  * @default 'string'
@@ -89,6 +96,7 @@ export type Options = {
89
96
 
90
97
  type ResolvedOptions = {
91
98
  enumType: NonNullable<Options['enumType']>
99
+ enumSuffix: NonNullable<Options['enumSuffix']>
92
100
  dateType: NonNullable<Options['dateType']>
93
101
  unknownType: NonNullable<Options['unknownType']>
94
102
  optionalType: NonNullable<Options['optionalType']>
@@ -103,9 +111,7 @@ export type FileMeta = {
103
111
  tag?: string
104
112
  }
105
113
 
106
- type AppMeta = SwaggerAppMeta
107
-
108
- export type PluginOptions = PluginFactoryOptions<'swagger-ts', Options, ResolvedOptions, never, ResolvePathOptions, AppMeta>
114
+ export type PluginOptions = PluginFactoryOptions<'swagger-ts', Options, ResolvedOptions, never, ResolvePathOptions>
109
115
 
110
116
  declare module '@kubb/core' {
111
117
  export interface _Register {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { Editor, File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </Editor>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return this.#unknownReturn\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return this.#unknownReturn\n }\n\n get #unknownReturn() {\n if (this.options.unknownType === 'any') {\n return factory.keywordTypeNodes.any\n }\n\n return factory.keywordTypeNodes.unknown\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { Editor, File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, extName: '.ts', pluginKey })\n\n const Template = templates.default\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n </Editor>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { Editor, File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </Editor>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,UAAAC,SAAQ,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAC1D,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOC,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAC,kBAAiB;AAC1B,OAAOC,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYC,cAAa;AACzB,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,iBAAiB;;;ACDhD,SAAS,QAAQ,MAAM,MAAM,iBAAiB;AAC9C,SAAS,eAAe;AACxB,SAAS,cAAc;AAqBnB,mBAEE,KAFF;AANJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE,iCACG;AAAA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","print","factory","Editor","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","transformers","print","Generator","transformers","factory","keywordTypeNodes","Template","pluginKey","Editor","File","usePlugin","useOas","Fragment","jsx","jsxs","usePlugin","useOas","Editor","File","jsx","transformers","options","Generator","transformers","node","path","keywordTypeNodes","transformers","print","Fragment","jsx","jsxs","printCombinedSchema","transformers","print","usePlugin","useSchemas","usePluginManager","useOas","useOperationFile","useOperationName","useOperation","Editor","File"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","Editor","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,UAAAC,SAAQ,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAC1D,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOX,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAW,kBAAiB;AAC1B,OAAOZ,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAW,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS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,gBAAAa,KAACb,MAAK,QAAL,EAAwB,MAAM,KAAK,MAAO,GAAG,QAA5B,KAAkC;AAAA,QAC7D,CAAC;AAAA,QACD,gBAAAc,MAACd,MAAK,QAAL,EACE;AAAA;AAAA,UACAkB,qBAAoB,aAAa,WAAW,OAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { Editor, File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </Editor>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return this.#unknownReturn\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return this.#unknownReturn\n }\n\n get #unknownReturn() {\n if (this.options.unknownType === 'any') {\n return factory.keywordTypeNodes.any\n }\n\n return factory.keywordTypeNodes.unknown\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { Editor, File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, extName: '.ts', pluginKey })\n\n const Template = templates.default\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n </Editor>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { Editor, File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </Editor>\n )\n}\n"]}