@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.
- package/dist/{chunk-S3YBOGZU.cjs → chunk-2M6PDW4T.cjs} +19 -15
- package/dist/chunk-2M6PDW4T.cjs.map +1 -0
- package/dist/{chunk-AINA467R.js → chunk-65CJCKDZ.js} +46 -42
- package/dist/chunk-65CJCKDZ.js.map +1 -0
- package/dist/{chunk-D5E6VJUL.cjs → chunk-WETJULJE.cjs} +44 -41
- package/dist/chunk-WETJULJE.cjs.map +1 -0
- package/dist/{chunk-PIS5H4LF.js → chunk-Z7RYCWNL.js} +11 -7
- package/dist/chunk-Z7RYCWNL.js.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.d.cts +3 -2
- package/dist/components.d.ts +3 -2
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Dy6NIaQp.d.cts → types-9taMMp9y.d.cts} +6 -0
- package/dist/{types-Dy6NIaQp.d.ts → types-9taMMp9y.d.ts} +6 -0
- package/package.json +10 -10
- package/src/components/Type.tsx +45 -39
- package/src/generators/__snapshots__/bodyUploadFileApiAssetsPost.ts +5 -5
- package/src/generators/__snapshots__/catTypeAsConst.ts +10 -10
- package/src/generators/__snapshots__/createPet.ts +27 -28
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +27 -28
- package/src/generators/__snapshots__/deletePet.ts +5 -6
- package/src/generators/__snapshots__/dogTypeAsConst.ts +10 -10
- package/src/generators/__snapshots__/enumAllOf.ts +7 -7
- package/src/generators/__snapshots__/enumArray.ts +12 -16
- package/src/generators/__snapshots__/enumInObject.ts +10 -10
- package/src/generators/__snapshots__/enumItems.ts +5 -5
- package/src/generators/__snapshots__/enumNames.ts +3 -3
- package/src/generators/__snapshots__/enumNamesConst.ts +3 -3
- package/src/generators/__snapshots__/enumNamesLiteral.ts +2 -2
- package/src/generators/__snapshots__/enumNamesPascalConst.ts +5 -5
- package/src/generators/__snapshots__/enumNamesType.ts +5 -5
- package/src/generators/__snapshots__/enumNullableMember.ts +5 -5
- package/src/generators/__snapshots__/enumNullableType.ts +5 -5
- package/src/generators/__snapshots__/enumString.ts +7 -7
- package/src/generators/__snapshots__/enumVarNamesType.ts +5 -5
- package/src/generators/__snapshots__/getPets.ts +19 -20
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -6
- package/src/generators/__snapshots__/nullConstNull.ts +4 -5
- package/src/generators/__snapshots__/numberValueConst.ts +6 -6
- package/src/generators/__snapshots__/petMapper.ts +14 -14
- package/src/generators/__snapshots__/petQuestionToken.ts +18 -19
- package/src/generators/__snapshots__/petQuestionTokenAndUndefined.ts +18 -19
- package/src/generators/__snapshots__/petUndefined.ts +18 -19
- package/src/generators/__snapshots__/pets.ts +13 -13
- package/src/generators/__snapshots__/petsInterface.ts +14 -0
- package/src/generators/__snapshots__/petsStoreAdvancedDiscriminator.ts +32 -29
- package/src/generators/__snapshots__/petsStoreDiscriminator.ts +10 -10
- package/src/generators/__snapshots__/petsStoreRef.ts +1 -1
- package/src/generators/__snapshots__/plainDateDate.ts +1 -1
- package/src/generators/__snapshots__/plainDateString.ts +1 -1
- package/src/generators/__snapshots__/plainEmail.ts +1 -1
- package/src/generators/__snapshots__/plainFile.ts +1 -1
- package/src/generators/__snapshots__/plainTimeDate.ts +1 -1
- package/src/generators/__snapshots__/plainUuid.ts +1 -1
- package/src/generators/__snapshots__/readOnly.ts +19 -20
- package/src/generators/__snapshots__/showPetById.ts +24 -25
- package/src/generators/__snapshots__/stringValueConst.ts +6 -6
- package/src/generators/typeGenerator.tsx +4 -2
- package/src/parser/index.ts +2 -1
- package/src/plugin.ts +2 -0
- package/src/types.ts +6 -0
- package/dist/chunk-AINA467R.js.map +0 -1
- package/dist/chunk-D5E6VJUL.cjs.map +0 -1
- package/dist/chunk-PIS5H4LF.js.map +0 -1
- 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
|
-
|
|
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
|
-
|
|
24
|
+
export type ShowPetByIdQueryResponse = showPetById200
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
26
|
+
export type showPetByIdQuery = {
|
|
27
|
+
Response: showPetById200
|
|
28
|
+
PathParams: showPetByIdPathParams
|
|
29
|
+
Errors: any
|
|
30
|
+
}
|
|
@@ -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
|
)
|
package/src/parser/index.ts
CHANGED
|
@@ -121,7 +121,7 @@ export const typeKeywordMapper = {
|
|
|
121
121
|
|
|
122
122
|
type ParserOptions = {
|
|
123
123
|
name: string
|
|
124
|
-
|
|
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
|
}
|