@kubb/plugin-ts 3.1.0 → 3.3.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.
Files changed (73) hide show
  1. package/dist/{chunk-S3YBOGZU.cjs → chunk-2M6PDW4T.cjs} +19 -15
  2. package/dist/chunk-2M6PDW4T.cjs.map +1 -0
  3. package/dist/{chunk-AINA467R.js → chunk-65CJCKDZ.js} +46 -42
  4. package/dist/chunk-65CJCKDZ.js.map +1 -0
  5. package/dist/{chunk-D5E6VJUL.cjs → chunk-WETJULJE.cjs} +44 -41
  6. package/dist/chunk-WETJULJE.cjs.map +1 -0
  7. package/dist/{chunk-PIS5H4LF.js → chunk-Z7RYCWNL.js} +11 -7
  8. package/dist/chunk-Z7RYCWNL.js.map +1 -0
  9. package/dist/components.cjs +3 -3
  10. package/dist/components.d.cts +3 -2
  11. package/dist/components.d.ts +3 -2
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +4 -4
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +4 -4
  18. package/dist/index.d.cts +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/{types-Dy6NIaQp.d.cts → types-9taMMp9y.d.cts} +6 -0
  22. package/dist/{types-Dy6NIaQp.d.ts → types-9taMMp9y.d.ts} +6 -0
  23. package/package.json +10 -10
  24. package/src/components/Type.tsx +45 -39
  25. package/src/generators/__snapshots__/bodyUploadFileApiAssetsPost.ts +5 -5
  26. package/src/generators/__snapshots__/catTypeAsConst.ts +10 -10
  27. package/src/generators/__snapshots__/createPet.ts +27 -28
  28. package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +27 -28
  29. package/src/generators/__snapshots__/deletePet.ts +5 -6
  30. package/src/generators/__snapshots__/dogTypeAsConst.ts +10 -10
  31. package/src/generators/__snapshots__/enumAllOf.ts +7 -7
  32. package/src/generators/__snapshots__/enumArray.ts +12 -16
  33. package/src/generators/__snapshots__/enumInObject.ts +10 -10
  34. package/src/generators/__snapshots__/enumItems.ts +5 -5
  35. package/src/generators/__snapshots__/enumNames.ts +3 -3
  36. package/src/generators/__snapshots__/enumNamesConst.ts +3 -3
  37. package/src/generators/__snapshots__/enumNamesLiteral.ts +2 -2
  38. package/src/generators/__snapshots__/enumNamesPascalConst.ts +5 -5
  39. package/src/generators/__snapshots__/enumNamesType.ts +5 -5
  40. package/src/generators/__snapshots__/enumNullableMember.ts +5 -5
  41. package/src/generators/__snapshots__/enumNullableType.ts +5 -5
  42. package/src/generators/__snapshots__/enumString.ts +7 -7
  43. package/src/generators/__snapshots__/enumVarNamesType.ts +5 -5
  44. package/src/generators/__snapshots__/getPets.ts +19 -20
  45. package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -6
  46. package/src/generators/__snapshots__/nullConstNull.ts +4 -5
  47. package/src/generators/__snapshots__/numberValueConst.ts +6 -6
  48. package/src/generators/__snapshots__/petMapper.ts +14 -14
  49. package/src/generators/__snapshots__/petQuestionToken.ts +18 -19
  50. package/src/generators/__snapshots__/petQuestionTokenAndUndefined.ts +18 -19
  51. package/src/generators/__snapshots__/petUndefined.ts +18 -19
  52. package/src/generators/__snapshots__/pets.ts +13 -13
  53. package/src/generators/__snapshots__/petsInterface.ts +14 -0
  54. package/src/generators/__snapshots__/petsStoreAdvancedDiscriminator.ts +32 -29
  55. package/src/generators/__snapshots__/petsStoreDiscriminator.ts +10 -10
  56. package/src/generators/__snapshots__/petsStoreRef.ts +1 -1
  57. package/src/generators/__snapshots__/plainDateDate.ts +1 -1
  58. package/src/generators/__snapshots__/plainDateString.ts +1 -1
  59. package/src/generators/__snapshots__/plainEmail.ts +1 -1
  60. package/src/generators/__snapshots__/plainFile.ts +1 -1
  61. package/src/generators/__snapshots__/plainTimeDate.ts +1 -1
  62. package/src/generators/__snapshots__/plainUuid.ts +1 -1
  63. package/src/generators/__snapshots__/readOnly.ts +19 -20
  64. package/src/generators/__snapshots__/showPetById.ts +24 -25
  65. package/src/generators/__snapshots__/stringValueConst.ts +6 -6
  66. package/src/generators/typeGenerator.tsx +4 -2
  67. package/src/parser/index.ts +2 -1
  68. package/src/plugin.ts +2 -0
  69. package/src/types.ts +6 -0
  70. package/dist/chunk-AINA467R.js.map +0 -1
  71. package/dist/chunk-D5E6VJUL.cjs.map +0 -1
  72. package/dist/chunk-PIS5H4LF.js.map +0 -1
  73. package/dist/chunk-S3YBOGZU.cjs.map +0 -1
@@ -1,31 +1,30 @@
1
+ export type ShowPetByIdPathParams = {
2
+ /**
3
+ * @description The id of the pet to retrieve
4
+ * @type string
5
+ */
6
+ petId: string
7
+ /**
8
+ * @description The id of the pet to retrieve
9
+ * @type string
10
+ */
11
+ testId: string
12
+ }
1
13
 
2
- export type ShowPetByIdPathParams = {
3
- /**
4
- * @description The id of the pet to retrieve
5
- * @type string
6
- */
7
- petId: string;
8
- /**
9
- * @description The id of the pet to retrieve
10
- * @type string
11
- */
12
- testId: string;
13
- };
14
-
15
- /**
14
+ /**
16
15
  * @description Expected response to a valid request
17
- */
18
- export type ShowPetById200 = pet;
16
+ */
17
+ export type ShowPetById200 = pet
19
18
 
20
- /**
19
+ /**
21
20
  * @description unexpected error
22
- */
23
- export type ShowPetByIdError = error;
21
+ */
22
+ export type ShowPetByIdError = error
24
23
 
25
- export type ShowPetByIdQueryResponse = showPetById200;
24
+ export type ShowPetByIdQueryResponse = showPetById200
26
25
 
27
- export type showPetByIdQuery = {
28
- Response: showPetById200;
29
- PathParams: showPetByIdPathParams;
30
- Errors: any;
31
- };
26
+ export type showPetByIdQuery = {
27
+ Response: showPetById200
28
+ PathParams: showPetByIdPathParams
29
+ Errors: any
30
+ }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @description its value is equal to the value of the keyword
3
- */
3
+ */
4
4
  export type stringValueConst = {
5
- /**
6
- * @type string | undefined
7
- */
8
- foobar?: "foobar";
9
- };
5
+ /**
6
+ * @type string | undefined
7
+ */
8
+ foobar?: 'foobar'
9
+ }
@@ -104,7 +104,7 @@ function printCombinedSchema({ name, schemas, pluginManager }: { name: string; s
104
104
  export const typeGenerator = createReactGenerator<PluginTs>({
105
105
  name: 'typescript',
106
106
  Operation({ operation, options }) {
107
- const { mapper, enumType, optionalType } = options
107
+ const { mapper, enumType, syntaxType, optionalType } = options
108
108
 
109
109
  const { plugin, pluginManager, mode } = useApp<PluginTs>()
110
110
  const oas = useOas()
@@ -150,6 +150,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
150
150
  enumType={enumType}
151
151
  optionalType={optionalType}
152
152
  keysToOmit={keysToOmit}
153
+ syntaxType={syntaxType}
153
154
  />
154
155
  </Oas.Schema>
155
156
  )
@@ -166,7 +167,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
166
167
  )
167
168
  },
168
169
  Schema({ schema, options }) {
169
- const { mapper, enumType, optionalType } = options
170
+ const { mapper, enumType, syntaxType, optionalType } = options
170
171
  const {
171
172
  mode,
172
173
  plugin: {
@@ -198,6 +199,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
198
199
  mapper={mapper}
199
200
  enumType={enumType}
200
201
  optionalType={optionalType}
202
+ syntaxType={syntaxType}
201
203
  />
202
204
  </File>
203
205
  )
@@ -121,7 +121,7 @@ export const typeKeywordMapper = {
121
121
 
122
122
  type ParserOptions = {
123
123
  name: string
124
- typeName?: string
124
+ typedName?: string
125
125
  description?: string
126
126
  /**
127
127
  * @default `'questionToken'`
@@ -132,6 +132,7 @@ type ParserOptions = {
132
132
  * asPascalConst is deprecated
133
133
  */
134
134
  enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
135
+ syntaxType: 'type' | 'interface'
135
136
  keysToOmit?: string[]
136
137
  mapper?: Record<string, ts.PropertySignature>
137
138
  }
package/src/plugin.ts CHANGED
@@ -23,6 +23,7 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
23
23
  dateType = 'string',
24
24
  unknownType = 'any',
25
25
  optionalType = 'questionToken',
26
+ syntaxType = 'type',
26
27
  transformers = {},
27
28
  oasType = false,
28
29
  mapper = {},
@@ -42,6 +43,7 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
42
43
  // keep the used enumnames between SchemaGenerator and OperationGenerator per plugin(pluginKey)
43
44
  usedEnumNames: {},
44
45
  unknownType,
46
+ syntaxType,
45
47
  group,
46
48
  override,
47
49
  mapper,
package/src/types.ts CHANGED
@@ -30,6 +30,11 @@ export type Options = {
30
30
  * asPascalConst is deprecated
31
31
  */
32
32
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
33
+ /**
34
+ * Switch between type or interface for creating TypeScript types
35
+ * @default 'type'
36
+ */
37
+ syntaxType?: 'type' | 'interface'
33
38
  /**
34
39
  * Set a suffix for the generated enums.
35
40
  * @default 'enum'
@@ -91,6 +96,7 @@ type ResolvedOptions = {
91
96
  optionalType: NonNullable<Options['optionalType']>
92
97
  transformers: NonNullable<Options['transformers']>
93
98
  oasType: NonNullable<Options['oasType']>
99
+ syntaxType: NonNullable<Options['syntaxType']>
94
100
  usedEnumNames: Record<string, number>
95
101
  mapper: Record<string, any>
96
102
  }