@kubb/swagger-ts 1.0.3 → 1.1.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/index.cjs +26 -20
- package/dist/index.js +26 -20
- package/package.json +4 -4
- package/src/generators/TypeGenerator.ts +34 -24
package/dist/index.cjs
CHANGED
|
@@ -172,33 +172,39 @@ var _TypeGenerator = class extends core.SchemaGenerator {
|
|
|
172
172
|
}
|
|
173
173
|
if (schema.oneOf) {
|
|
174
174
|
const schemaWithoutOneOf = { ...schema, oneOf: void 0 };
|
|
175
|
+
const union = factory2.createParenthesizedType(
|
|
176
|
+
tsCodegen.createUnionDeclaration({
|
|
177
|
+
nodes: schema.oneOf.map((item) => {
|
|
178
|
+
return this.getBaseTypeFromSchema(item);
|
|
179
|
+
}).filter(Boolean)
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
if (schemaWithoutOneOf.properties) {
|
|
183
|
+
return tsCodegen.createIntersectionDeclaration({
|
|
184
|
+
nodes: [this.getBaseTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
175
187
|
return tsCodegen.createIntersectionDeclaration({
|
|
176
|
-
nodes: [
|
|
177
|
-
this.getBaseTypeFromSchema(schemaWithoutOneOf, baseName),
|
|
178
|
-
factory2.createParenthesizedType(
|
|
179
|
-
tsCodegen.createUnionDeclaration({
|
|
180
|
-
nodes: schema.oneOf.map((item) => {
|
|
181
|
-
return this.getBaseTypeFromSchema(item);
|
|
182
|
-
}).filter(Boolean)
|
|
183
|
-
})
|
|
184
|
-
)
|
|
185
|
-
].filter(Boolean)
|
|
188
|
+
nodes: [union]
|
|
186
189
|
});
|
|
187
190
|
}
|
|
188
191
|
if (schema.anyOf) ;
|
|
189
192
|
if (schema.allOf) {
|
|
190
193
|
const schemaWithoutAllOf = { ...schema, allOf: void 0 };
|
|
194
|
+
const and = factory2.createParenthesizedType(
|
|
195
|
+
factory2.createIntersectionTypeNode(
|
|
196
|
+
schema.allOf.map((item) => {
|
|
197
|
+
return this.getBaseTypeFromSchema(item);
|
|
198
|
+
}).filter(Boolean)
|
|
199
|
+
)
|
|
200
|
+
);
|
|
201
|
+
if (schemaWithoutAllOf.properties) {
|
|
202
|
+
return tsCodegen.createIntersectionDeclaration({
|
|
203
|
+
nodes: [this.getBaseTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
191
206
|
return tsCodegen.createIntersectionDeclaration({
|
|
192
|
-
nodes: [
|
|
193
|
-
this.getBaseTypeFromSchema(schemaWithoutAllOf, baseName),
|
|
194
|
-
factory2.createParenthesizedType(
|
|
195
|
-
factory2.createIntersectionTypeNode(
|
|
196
|
-
schema.allOf.map((item) => {
|
|
197
|
-
return this.getBaseTypeFromSchema(item);
|
|
198
|
-
}).filter(Boolean)
|
|
199
|
-
)
|
|
200
|
-
)
|
|
201
|
-
].filter(Boolean)
|
|
207
|
+
nodes: [and]
|
|
202
208
|
});
|
|
203
209
|
}
|
|
204
210
|
if (schema.enum && baseName) {
|
package/dist/index.js
CHANGED
|
@@ -162,33 +162,39 @@ var _TypeGenerator = class extends SchemaGenerator {
|
|
|
162
162
|
}
|
|
163
163
|
if (schema.oneOf) {
|
|
164
164
|
const schemaWithoutOneOf = { ...schema, oneOf: void 0 };
|
|
165
|
+
const union = factory2.createParenthesizedType(
|
|
166
|
+
createUnionDeclaration({
|
|
167
|
+
nodes: schema.oneOf.map((item) => {
|
|
168
|
+
return this.getBaseTypeFromSchema(item);
|
|
169
|
+
}).filter(Boolean)
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
if (schemaWithoutOneOf.properties) {
|
|
173
|
+
return createIntersectionDeclaration({
|
|
174
|
+
nodes: [this.getBaseTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
165
177
|
return createIntersectionDeclaration({
|
|
166
|
-
nodes: [
|
|
167
|
-
this.getBaseTypeFromSchema(schemaWithoutOneOf, baseName),
|
|
168
|
-
factory2.createParenthesizedType(
|
|
169
|
-
createUnionDeclaration({
|
|
170
|
-
nodes: schema.oneOf.map((item) => {
|
|
171
|
-
return this.getBaseTypeFromSchema(item);
|
|
172
|
-
}).filter(Boolean)
|
|
173
|
-
})
|
|
174
|
-
)
|
|
175
|
-
].filter(Boolean)
|
|
178
|
+
nodes: [union]
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
if (schema.anyOf) ;
|
|
179
182
|
if (schema.allOf) {
|
|
180
183
|
const schemaWithoutAllOf = { ...schema, allOf: void 0 };
|
|
184
|
+
const and = factory2.createParenthesizedType(
|
|
185
|
+
factory2.createIntersectionTypeNode(
|
|
186
|
+
schema.allOf.map((item) => {
|
|
187
|
+
return this.getBaseTypeFromSchema(item);
|
|
188
|
+
}).filter(Boolean)
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
if (schemaWithoutAllOf.properties) {
|
|
192
|
+
return createIntersectionDeclaration({
|
|
193
|
+
nodes: [this.getBaseTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
181
196
|
return createIntersectionDeclaration({
|
|
182
|
-
nodes: [
|
|
183
|
-
this.getBaseTypeFromSchema(schemaWithoutAllOf, baseName),
|
|
184
|
-
factory2.createParenthesizedType(
|
|
185
|
-
factory2.createIntersectionTypeNode(
|
|
186
|
-
schema.allOf.map((item) => {
|
|
187
|
-
return this.getBaseTypeFromSchema(item);
|
|
188
|
-
}).filter(Boolean)
|
|
189
|
-
)
|
|
190
|
-
)
|
|
191
|
-
].filter(Boolean)
|
|
197
|
+
nodes: [and]
|
|
192
198
|
});
|
|
193
199
|
}
|
|
194
200
|
if (schema.enum && baseName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/swagger-ts",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Generator swagger-ts",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"change-case": "^4.1.2",
|
|
42
42
|
"lodash.uniqueid": "^4.0.1",
|
|
43
43
|
"typescript": "^5.1.3",
|
|
44
|
-
"@kubb/core": "1.0
|
|
45
|
-
"@kubb/swagger": "1.0
|
|
46
|
-
"@kubb/ts-codegen": "1.0
|
|
44
|
+
"@kubb/core": "1.1.0",
|
|
45
|
+
"@kubb/swagger": "1.1.0",
|
|
46
|
+
"@kubb/ts-codegen": "1.1.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/lodash.uniqueid": "^4.0.7",
|
|
@@ -205,19 +205,24 @@ export class TypeGenerator extends SchemaGenerator<Options, OpenAPIV3.SchemaObje
|
|
|
205
205
|
// union
|
|
206
206
|
const schemaWithoutOneOf = { ...schema, oneOf: undefined }
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
nodes: schema.oneOf
|
|
214
|
-
.map((item) => {
|
|
215
|
-
return this.getBaseTypeFromSchema(item)
|
|
216
|
-
})
|
|
217
|
-
.filter(Boolean) as ts.TypeNode[],
|
|
208
|
+
const union = factory.createParenthesizedType(
|
|
209
|
+
createUnionDeclaration({
|
|
210
|
+
nodes: schema.oneOf
|
|
211
|
+
.map((item) => {
|
|
212
|
+
return this.getBaseTypeFromSchema(item)
|
|
218
213
|
})
|
|
219
|
-
|
|
220
|
-
|
|
214
|
+
.filter(Boolean) as ts.TypeNode[],
|
|
215
|
+
})
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
if (schemaWithoutOneOf.properties) {
|
|
219
|
+
return createIntersectionDeclaration({
|
|
220
|
+
nodes: [this.getBaseTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean) as ts.TypeNode[],
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return createIntersectionDeclaration({
|
|
225
|
+
nodes: [union],
|
|
221
226
|
})
|
|
222
227
|
}
|
|
223
228
|
|
|
@@ -228,19 +233,24 @@ export class TypeGenerator extends SchemaGenerator<Options, OpenAPIV3.SchemaObje
|
|
|
228
233
|
// intersection/add
|
|
229
234
|
const schemaWithoutAllOf = { ...schema, allOf: undefined }
|
|
230
235
|
|
|
236
|
+
const and = factory.createParenthesizedType(
|
|
237
|
+
factory.createIntersectionTypeNode(
|
|
238
|
+
schema.allOf
|
|
239
|
+
.map((item) => {
|
|
240
|
+
return this.getBaseTypeFromSchema(item)
|
|
241
|
+
})
|
|
242
|
+
.filter(Boolean) as ts.TypeNode[]
|
|
243
|
+
)
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
if (schemaWithoutAllOf.properties) {
|
|
247
|
+
return createIntersectionDeclaration({
|
|
248
|
+
nodes: [this.getBaseTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean) as ts.TypeNode[],
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
|
|
231
252
|
return createIntersectionDeclaration({
|
|
232
|
-
nodes: [
|
|
233
|
-
this.getBaseTypeFromSchema(schemaWithoutAllOf, baseName),
|
|
234
|
-
factory.createParenthesizedType(
|
|
235
|
-
factory.createIntersectionTypeNode(
|
|
236
|
-
schema.allOf
|
|
237
|
-
.map((item) => {
|
|
238
|
-
return this.getBaseTypeFromSchema(item)
|
|
239
|
-
})
|
|
240
|
-
.filter(Boolean) as ts.TypeNode[]
|
|
241
|
-
)
|
|
242
|
-
),
|
|
243
|
-
].filter(Boolean) as ts.TypeNode[],
|
|
253
|
+
nodes: [and],
|
|
244
254
|
})
|
|
245
255
|
}
|
|
246
256
|
|