next-openapi-gen 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +93 -90
- package/dist/index.js +93 -90
- package/dist/next/index.js +93 -90
- package/dist/react-router/index.js +4 -5
- package/dist/vite/index.js +4 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13337,7 +13337,7 @@ var ZodSchemaConverter = class {
|
|
|
13337
13337
|
return helperName.startsWith("coerce.") || helperName === "templateLiteral" || helperName === "stringbool";
|
|
13338
13338
|
}
|
|
13339
13339
|
if (t10.isMemberExpression(node.callee) && t10.isIdentifier(node.callee.property)) {
|
|
13340
|
-
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"
|
|
13340
|
+
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"]);
|
|
13341
13341
|
if (runtimeMethods.has(node.callee.property.name)) {
|
|
13342
13342
|
return true;
|
|
13343
13343
|
}
|
|
@@ -13514,15 +13514,13 @@ var ZodSchemaConverter = class {
|
|
|
13514
13514
|
schema.type = "integer";
|
|
13515
13515
|
break;
|
|
13516
13516
|
case "positive":
|
|
13517
|
-
schema.
|
|
13518
|
-
schema.exclusiveMinimum = true;
|
|
13517
|
+
schema.exclusiveMinimum = 0;
|
|
13519
13518
|
break;
|
|
13520
13519
|
case "nonnegative":
|
|
13521
13520
|
schema.minimum = 0;
|
|
13522
13521
|
break;
|
|
13523
13522
|
case "negative":
|
|
13524
|
-
schema.
|
|
13525
|
-
schema.exclusiveMaximum = true;
|
|
13523
|
+
schema.exclusiveMaximum = 0;
|
|
13526
13524
|
break;
|
|
13527
13525
|
case "nonpositive":
|
|
13528
13526
|
schema.maximum = 0;
|
|
@@ -17378,6 +17376,7 @@ function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
|
17378
17376
|
if (excludedNames.size === 0)
|
|
17379
17377
|
return;
|
|
17380
17378
|
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
17379
|
+
walkAndInline(mergedSchemas, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
17381
17380
|
for (const name of excludedNames) {
|
|
17382
17381
|
delete mergedSchemas[name];
|
|
17383
17382
|
}
|
|
@@ -18157,96 +18156,100 @@ function typeToOpenApiSchema(type, checker, seen) {
|
|
|
18157
18156
|
return { type: "object" };
|
|
18158
18157
|
}
|
|
18159
18158
|
seen.add(seenKey);
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
|
|
18167
|
-
|
|
18168
|
-
type: "boolean",
|
|
18169
|
-
enum: [checker.typeToString(type) === "true"]
|
|
18170
|
-
};
|
|
18171
|
-
}
|
|
18172
|
-
if (type.flags & ts3.TypeFlags.TemplateLiteral) {
|
|
18173
|
-
return { type: "string" };
|
|
18174
|
-
}
|
|
18175
|
-
if (type.flags & ts3.TypeFlags.StringLike) {
|
|
18176
|
-
return { type: "string" };
|
|
18177
|
-
}
|
|
18178
|
-
if (type.flags & ts3.TypeFlags.NumberLike) {
|
|
18179
|
-
return { type: "number" };
|
|
18180
|
-
}
|
|
18181
|
-
if (type.flags & ts3.TypeFlags.BooleanLike) {
|
|
18182
|
-
return { type: "boolean" };
|
|
18183
|
-
}
|
|
18184
|
-
if (type.flags & ts3.TypeFlags.Null) {
|
|
18185
|
-
return { type: "null" };
|
|
18186
|
-
}
|
|
18187
|
-
if (type.isUnion()) {
|
|
18188
|
-
const nullable2 = type.types.some((member) => member.flags & ts3.TypeFlags.Null);
|
|
18189
|
-
const nonNullTypes = type.types.filter((member) => !(member.flags & ts3.TypeFlags.Null));
|
|
18190
|
-
const soleNonNullType = nonNullTypes[0];
|
|
18191
|
-
if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
|
|
18159
|
+
try {
|
|
18160
|
+
if (type.isStringLiteral()) {
|
|
18161
|
+
return { type: "string", enum: [type.value] };
|
|
18162
|
+
}
|
|
18163
|
+
if (type.isNumberLiteral()) {
|
|
18164
|
+
return { type: "number", enum: [type.value] };
|
|
18165
|
+
}
|
|
18166
|
+
if (type.flags & ts3.TypeFlags.BooleanLiteral) {
|
|
18192
18167
|
return {
|
|
18193
|
-
|
|
18194
|
-
|
|
18168
|
+
type: "boolean",
|
|
18169
|
+
enum: [checker.typeToString(type) === "true"]
|
|
18195
18170
|
};
|
|
18196
18171
|
}
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
}
|
|
18200
|
-
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
|
|
18204
|
-
type: "
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
type
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
const required2 = [];
|
|
18222
|
-
properties.forEach((property) => {
|
|
18223
|
-
const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
|
|
18224
|
-
if (!propertyDeclaration) {
|
|
18225
|
-
return;
|
|
18226
|
-
}
|
|
18227
|
-
const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
|
|
18228
|
-
schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
|
|
18229
|
-
if (!(property.flags & ts3.SymbolFlags.Optional)) {
|
|
18230
|
-
required2.push(property.getName());
|
|
18172
|
+
if (type.flags & ts3.TypeFlags.TemplateLiteral) {
|
|
18173
|
+
return { type: "string" };
|
|
18174
|
+
}
|
|
18175
|
+
if (type.flags & ts3.TypeFlags.StringLike) {
|
|
18176
|
+
return { type: "string" };
|
|
18177
|
+
}
|
|
18178
|
+
if (type.flags & ts3.TypeFlags.NumberLike) {
|
|
18179
|
+
return { type: "number" };
|
|
18180
|
+
}
|
|
18181
|
+
if (type.flags & ts3.TypeFlags.BooleanLike) {
|
|
18182
|
+
return { type: "boolean" };
|
|
18183
|
+
}
|
|
18184
|
+
if (type.flags & ts3.TypeFlags.Null) {
|
|
18185
|
+
return { type: "null" };
|
|
18186
|
+
}
|
|
18187
|
+
if (type.isUnion()) {
|
|
18188
|
+
const nullable2 = type.types.some((member) => member.flags & ts3.TypeFlags.Null);
|
|
18189
|
+
const nonNullTypes = type.types.filter((member) => !(member.flags & ts3.TypeFlags.Null));
|
|
18190
|
+
const soleNonNullType = nonNullTypes[0];
|
|
18191
|
+
if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
|
|
18192
|
+
return {
|
|
18193
|
+
...typeToOpenApiSchema(soleNonNullType, checker, seen),
|
|
18194
|
+
nullable: true
|
|
18195
|
+
};
|
|
18231
18196
|
}
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
-
|
|
18197
|
+
return {
|
|
18198
|
+
oneOf: nonNullTypes.map((member) => typeToOpenApiSchema(member, checker, seen))
|
|
18199
|
+
};
|
|
18200
|
+
}
|
|
18201
|
+
if (checker.isTupleType(type)) {
|
|
18202
|
+
const itemTypes = checker.getTypeArguments(type);
|
|
18203
|
+
return {
|
|
18204
|
+
type: "array",
|
|
18205
|
+
prefixItems: itemTypes.map((itemType) => typeToOpenApiSchema(itemType, checker, seen)),
|
|
18206
|
+
items: false,
|
|
18207
|
+
minItems: itemTypes.length,
|
|
18208
|
+
maxItems: itemTypes.length
|
|
18209
|
+
};
|
|
18210
|
+
}
|
|
18211
|
+
if (checker.isArrayType(type)) {
|
|
18212
|
+
const elementType = checker.getTypeArguments(type)[0];
|
|
18213
|
+
return {
|
|
18214
|
+
type: "array",
|
|
18215
|
+
items: elementType ? typeToOpenApiSchema(elementType, checker, seen) : { type: "object" }
|
|
18216
|
+
};
|
|
18217
|
+
}
|
|
18218
|
+
const properties = checker.getPropertiesOfType(type);
|
|
18219
|
+
if (properties.length > 0) {
|
|
18220
|
+
const schemaProperties = {};
|
|
18221
|
+
const required2 = [];
|
|
18222
|
+
properties.forEach((property) => {
|
|
18223
|
+
const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
|
|
18224
|
+
if (!propertyDeclaration) {
|
|
18225
|
+
return;
|
|
18226
|
+
}
|
|
18227
|
+
const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
|
|
18228
|
+
schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
|
|
18229
|
+
if (!(property.flags & ts3.SymbolFlags.Optional)) {
|
|
18230
|
+
required2.push(property.getName());
|
|
18231
|
+
}
|
|
18232
|
+
});
|
|
18233
|
+
return required2.length > 0 ? {
|
|
18234
|
+
type: "object",
|
|
18235
|
+
properties: schemaProperties,
|
|
18236
|
+
required: required2
|
|
18237
|
+
} : {
|
|
18238
|
+
type: "object",
|
|
18239
|
+
properties: schemaProperties
|
|
18240
|
+
};
|
|
18241
|
+
}
|
|
18242
|
+
const stringIndexType = type.getStringIndexType();
|
|
18243
|
+
if (stringIndexType) {
|
|
18244
|
+
return {
|
|
18245
|
+
type: "object",
|
|
18246
|
+
additionalProperties: typeToOpenApiSchema(stringIndexType, checker, seen)
|
|
18247
|
+
};
|
|
18248
|
+
}
|
|
18249
|
+
return { type: "object" };
|
|
18250
|
+
} finally {
|
|
18251
|
+
seen.delete(seenKey);
|
|
18248
18252
|
}
|
|
18249
|
-
return { type: "object" };
|
|
18250
18253
|
}
|
|
18251
18254
|
function unwrapPromiseType(type, checker) {
|
|
18252
18255
|
const symbolName = type.getSymbol()?.getName();
|
package/dist/index.js
CHANGED
|
@@ -12886,7 +12886,7 @@ var ZodSchemaConverter = class {
|
|
|
12886
12886
|
return helperName.startsWith("coerce.") || helperName === "templateLiteral" || helperName === "stringbool";
|
|
12887
12887
|
}
|
|
12888
12888
|
if (t10.isMemberExpression(node.callee) && t10.isIdentifier(node.callee.property)) {
|
|
12889
|
-
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"
|
|
12889
|
+
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"]);
|
|
12890
12890
|
if (runtimeMethods.has(node.callee.property.name)) {
|
|
12891
12891
|
return true;
|
|
12892
12892
|
}
|
|
@@ -13063,15 +13063,13 @@ var ZodSchemaConverter = class {
|
|
|
13063
13063
|
schema.type = "integer";
|
|
13064
13064
|
break;
|
|
13065
13065
|
case "positive":
|
|
13066
|
-
schema.
|
|
13067
|
-
schema.exclusiveMinimum = true;
|
|
13066
|
+
schema.exclusiveMinimum = 0;
|
|
13068
13067
|
break;
|
|
13069
13068
|
case "nonnegative":
|
|
13070
13069
|
schema.minimum = 0;
|
|
13071
13070
|
break;
|
|
13072
13071
|
case "negative":
|
|
13073
|
-
schema.
|
|
13074
|
-
schema.exclusiveMaximum = true;
|
|
13072
|
+
schema.exclusiveMaximum = 0;
|
|
13075
13073
|
break;
|
|
13076
13074
|
case "nonpositive":
|
|
13077
13075
|
schema.maximum = 0;
|
|
@@ -16927,6 +16925,7 @@ function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
|
16927
16925
|
if (excludedNames.size === 0)
|
|
16928
16926
|
return;
|
|
16929
16927
|
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16928
|
+
walkAndInline(mergedSchemas, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16930
16929
|
for (const name of excludedNames) {
|
|
16931
16930
|
delete mergedSchemas[name];
|
|
16932
16931
|
}
|
|
@@ -17859,96 +17858,100 @@ function typeToOpenApiSchema(type, checker, seen) {
|
|
|
17859
17858
|
return { type: "object" };
|
|
17860
17859
|
}
|
|
17861
17860
|
seen.add(seenKey);
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
type: "boolean",
|
|
17871
|
-
enum: [checker.typeToString(type) === "true"]
|
|
17872
|
-
};
|
|
17873
|
-
}
|
|
17874
|
-
if (type.flags & ts3.TypeFlags.TemplateLiteral) {
|
|
17875
|
-
return { type: "string" };
|
|
17876
|
-
}
|
|
17877
|
-
if (type.flags & ts3.TypeFlags.StringLike) {
|
|
17878
|
-
return { type: "string" };
|
|
17879
|
-
}
|
|
17880
|
-
if (type.flags & ts3.TypeFlags.NumberLike) {
|
|
17881
|
-
return { type: "number" };
|
|
17882
|
-
}
|
|
17883
|
-
if (type.flags & ts3.TypeFlags.BooleanLike) {
|
|
17884
|
-
return { type: "boolean" };
|
|
17885
|
-
}
|
|
17886
|
-
if (type.flags & ts3.TypeFlags.Null) {
|
|
17887
|
-
return { type: "null" };
|
|
17888
|
-
}
|
|
17889
|
-
if (type.isUnion()) {
|
|
17890
|
-
const nullable2 = type.types.some((member) => member.flags & ts3.TypeFlags.Null);
|
|
17891
|
-
const nonNullTypes = type.types.filter((member) => !(member.flags & ts3.TypeFlags.Null));
|
|
17892
|
-
const soleNonNullType = nonNullTypes[0];
|
|
17893
|
-
if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
|
|
17861
|
+
try {
|
|
17862
|
+
if (type.isStringLiteral()) {
|
|
17863
|
+
return { type: "string", enum: [type.value] };
|
|
17864
|
+
}
|
|
17865
|
+
if (type.isNumberLiteral()) {
|
|
17866
|
+
return { type: "number", enum: [type.value] };
|
|
17867
|
+
}
|
|
17868
|
+
if (type.flags & ts3.TypeFlags.BooleanLiteral) {
|
|
17894
17869
|
return {
|
|
17895
|
-
|
|
17896
|
-
|
|
17870
|
+
type: "boolean",
|
|
17871
|
+
enum: [checker.typeToString(type) === "true"]
|
|
17897
17872
|
};
|
|
17898
17873
|
}
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
}
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
type: "
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
type
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
const required2 = [];
|
|
17924
|
-
properties.forEach((property) => {
|
|
17925
|
-
const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
|
|
17926
|
-
if (!propertyDeclaration) {
|
|
17927
|
-
return;
|
|
17928
|
-
}
|
|
17929
|
-
const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
|
|
17930
|
-
schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
|
|
17931
|
-
if (!(property.flags & ts3.SymbolFlags.Optional)) {
|
|
17932
|
-
required2.push(property.getName());
|
|
17874
|
+
if (type.flags & ts3.TypeFlags.TemplateLiteral) {
|
|
17875
|
+
return { type: "string" };
|
|
17876
|
+
}
|
|
17877
|
+
if (type.flags & ts3.TypeFlags.StringLike) {
|
|
17878
|
+
return { type: "string" };
|
|
17879
|
+
}
|
|
17880
|
+
if (type.flags & ts3.TypeFlags.NumberLike) {
|
|
17881
|
+
return { type: "number" };
|
|
17882
|
+
}
|
|
17883
|
+
if (type.flags & ts3.TypeFlags.BooleanLike) {
|
|
17884
|
+
return { type: "boolean" };
|
|
17885
|
+
}
|
|
17886
|
+
if (type.flags & ts3.TypeFlags.Null) {
|
|
17887
|
+
return { type: "null" };
|
|
17888
|
+
}
|
|
17889
|
+
if (type.isUnion()) {
|
|
17890
|
+
const nullable2 = type.types.some((member) => member.flags & ts3.TypeFlags.Null);
|
|
17891
|
+
const nonNullTypes = type.types.filter((member) => !(member.flags & ts3.TypeFlags.Null));
|
|
17892
|
+
const soleNonNullType = nonNullTypes[0];
|
|
17893
|
+
if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
|
|
17894
|
+
return {
|
|
17895
|
+
...typeToOpenApiSchema(soleNonNullType, checker, seen),
|
|
17896
|
+
nullable: true
|
|
17897
|
+
};
|
|
17933
17898
|
}
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17899
|
+
return {
|
|
17900
|
+
oneOf: nonNullTypes.map((member) => typeToOpenApiSchema(member, checker, seen))
|
|
17901
|
+
};
|
|
17902
|
+
}
|
|
17903
|
+
if (checker.isTupleType(type)) {
|
|
17904
|
+
const itemTypes = checker.getTypeArguments(type);
|
|
17905
|
+
return {
|
|
17906
|
+
type: "array",
|
|
17907
|
+
prefixItems: itemTypes.map((itemType) => typeToOpenApiSchema(itemType, checker, seen)),
|
|
17908
|
+
items: false,
|
|
17909
|
+
minItems: itemTypes.length,
|
|
17910
|
+
maxItems: itemTypes.length
|
|
17911
|
+
};
|
|
17912
|
+
}
|
|
17913
|
+
if (checker.isArrayType(type)) {
|
|
17914
|
+
const elementType = checker.getTypeArguments(type)[0];
|
|
17915
|
+
return {
|
|
17916
|
+
type: "array",
|
|
17917
|
+
items: elementType ? typeToOpenApiSchema(elementType, checker, seen) : { type: "object" }
|
|
17918
|
+
};
|
|
17919
|
+
}
|
|
17920
|
+
const properties = checker.getPropertiesOfType(type);
|
|
17921
|
+
if (properties.length > 0) {
|
|
17922
|
+
const schemaProperties = {};
|
|
17923
|
+
const required2 = [];
|
|
17924
|
+
properties.forEach((property) => {
|
|
17925
|
+
const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
|
|
17926
|
+
if (!propertyDeclaration) {
|
|
17927
|
+
return;
|
|
17928
|
+
}
|
|
17929
|
+
const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
|
|
17930
|
+
schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
|
|
17931
|
+
if (!(property.flags & ts3.SymbolFlags.Optional)) {
|
|
17932
|
+
required2.push(property.getName());
|
|
17933
|
+
}
|
|
17934
|
+
});
|
|
17935
|
+
return required2.length > 0 ? {
|
|
17936
|
+
type: "object",
|
|
17937
|
+
properties: schemaProperties,
|
|
17938
|
+
required: required2
|
|
17939
|
+
} : {
|
|
17940
|
+
type: "object",
|
|
17941
|
+
properties: schemaProperties
|
|
17942
|
+
};
|
|
17943
|
+
}
|
|
17944
|
+
const stringIndexType = type.getStringIndexType();
|
|
17945
|
+
if (stringIndexType) {
|
|
17946
|
+
return {
|
|
17947
|
+
type: "object",
|
|
17948
|
+
additionalProperties: typeToOpenApiSchema(stringIndexType, checker, seen)
|
|
17949
|
+
};
|
|
17950
|
+
}
|
|
17951
|
+
return { type: "object" };
|
|
17952
|
+
} finally {
|
|
17953
|
+
seen.delete(seenKey);
|
|
17950
17954
|
}
|
|
17951
|
-
return { type: "object" };
|
|
17952
17955
|
}
|
|
17953
17956
|
function unwrapPromiseType(type, checker) {
|
|
17954
17957
|
const symbolName = type.getSymbol()?.getName();
|
package/dist/next/index.js
CHANGED
|
@@ -737,96 +737,100 @@ function typeToOpenApiSchema(type, checker, seen) {
|
|
|
737
737
|
return { type: "object" };
|
|
738
738
|
}
|
|
739
739
|
seen.add(seenKey);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
type: "boolean",
|
|
749
|
-
enum: [checker.typeToString(type) === "true"]
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
if (type.flags & ts2.TypeFlags.TemplateLiteral) {
|
|
753
|
-
return { type: "string" };
|
|
754
|
-
}
|
|
755
|
-
if (type.flags & ts2.TypeFlags.StringLike) {
|
|
756
|
-
return { type: "string" };
|
|
757
|
-
}
|
|
758
|
-
if (type.flags & ts2.TypeFlags.NumberLike) {
|
|
759
|
-
return { type: "number" };
|
|
760
|
-
}
|
|
761
|
-
if (type.flags & ts2.TypeFlags.BooleanLike) {
|
|
762
|
-
return { type: "boolean" };
|
|
763
|
-
}
|
|
764
|
-
if (type.flags & ts2.TypeFlags.Null) {
|
|
765
|
-
return { type: "null" };
|
|
766
|
-
}
|
|
767
|
-
if (type.isUnion()) {
|
|
768
|
-
const nullable2 = type.types.some((member) => member.flags & ts2.TypeFlags.Null);
|
|
769
|
-
const nonNullTypes = type.types.filter((member) => !(member.flags & ts2.TypeFlags.Null));
|
|
770
|
-
const soleNonNullType = nonNullTypes[0];
|
|
771
|
-
if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
|
|
740
|
+
try {
|
|
741
|
+
if (type.isStringLiteral()) {
|
|
742
|
+
return { type: "string", enum: [type.value] };
|
|
743
|
+
}
|
|
744
|
+
if (type.isNumberLiteral()) {
|
|
745
|
+
return { type: "number", enum: [type.value] };
|
|
746
|
+
}
|
|
747
|
+
if (type.flags & ts2.TypeFlags.BooleanLiteral) {
|
|
772
748
|
return {
|
|
773
|
-
|
|
774
|
-
|
|
749
|
+
type: "boolean",
|
|
750
|
+
enum: [checker.typeToString(type) === "true"]
|
|
775
751
|
};
|
|
776
752
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
type: "
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
type
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
const required2 = [];
|
|
802
|
-
properties.forEach((property) => {
|
|
803
|
-
const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
|
|
804
|
-
if (!propertyDeclaration) {
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
|
|
808
|
-
schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
|
|
809
|
-
if (!(property.flags & ts2.SymbolFlags.Optional)) {
|
|
810
|
-
required2.push(property.getName());
|
|
753
|
+
if (type.flags & ts2.TypeFlags.TemplateLiteral) {
|
|
754
|
+
return { type: "string" };
|
|
755
|
+
}
|
|
756
|
+
if (type.flags & ts2.TypeFlags.StringLike) {
|
|
757
|
+
return { type: "string" };
|
|
758
|
+
}
|
|
759
|
+
if (type.flags & ts2.TypeFlags.NumberLike) {
|
|
760
|
+
return { type: "number" };
|
|
761
|
+
}
|
|
762
|
+
if (type.flags & ts2.TypeFlags.BooleanLike) {
|
|
763
|
+
return { type: "boolean" };
|
|
764
|
+
}
|
|
765
|
+
if (type.flags & ts2.TypeFlags.Null) {
|
|
766
|
+
return { type: "null" };
|
|
767
|
+
}
|
|
768
|
+
if (type.isUnion()) {
|
|
769
|
+
const nullable2 = type.types.some((member) => member.flags & ts2.TypeFlags.Null);
|
|
770
|
+
const nonNullTypes = type.types.filter((member) => !(member.flags & ts2.TypeFlags.Null));
|
|
771
|
+
const soleNonNullType = nonNullTypes[0];
|
|
772
|
+
if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
|
|
773
|
+
return {
|
|
774
|
+
...typeToOpenApiSchema(soleNonNullType, checker, seen),
|
|
775
|
+
nullable: true
|
|
776
|
+
};
|
|
811
777
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
778
|
+
return {
|
|
779
|
+
oneOf: nonNullTypes.map((member) => typeToOpenApiSchema(member, checker, seen))
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
if (checker.isTupleType(type)) {
|
|
783
|
+
const itemTypes = checker.getTypeArguments(type);
|
|
784
|
+
return {
|
|
785
|
+
type: "array",
|
|
786
|
+
prefixItems: itemTypes.map((itemType) => typeToOpenApiSchema(itemType, checker, seen)),
|
|
787
|
+
items: false,
|
|
788
|
+
minItems: itemTypes.length,
|
|
789
|
+
maxItems: itemTypes.length
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
if (checker.isArrayType(type)) {
|
|
793
|
+
const elementType = checker.getTypeArguments(type)[0];
|
|
794
|
+
return {
|
|
795
|
+
type: "array",
|
|
796
|
+
items: elementType ? typeToOpenApiSchema(elementType, checker, seen) : { type: "object" }
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
const properties = checker.getPropertiesOfType(type);
|
|
800
|
+
if (properties.length > 0) {
|
|
801
|
+
const schemaProperties = {};
|
|
802
|
+
const required2 = [];
|
|
803
|
+
properties.forEach((property) => {
|
|
804
|
+
const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
|
|
805
|
+
if (!propertyDeclaration) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
|
|
809
|
+
schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
|
|
810
|
+
if (!(property.flags & ts2.SymbolFlags.Optional)) {
|
|
811
|
+
required2.push(property.getName());
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
return required2.length > 0 ? {
|
|
815
|
+
type: "object",
|
|
816
|
+
properties: schemaProperties,
|
|
817
|
+
required: required2
|
|
818
|
+
} : {
|
|
819
|
+
type: "object",
|
|
820
|
+
properties: schemaProperties
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
const stringIndexType = type.getStringIndexType();
|
|
824
|
+
if (stringIndexType) {
|
|
825
|
+
return {
|
|
826
|
+
type: "object",
|
|
827
|
+
additionalProperties: typeToOpenApiSchema(stringIndexType, checker, seen)
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
return { type: "object" };
|
|
831
|
+
} finally {
|
|
832
|
+
seen.delete(seenKey);
|
|
828
833
|
}
|
|
829
|
-
return { type: "object" };
|
|
830
834
|
}
|
|
831
835
|
function unwrapPromiseType(type, checker) {
|
|
832
836
|
const symbolName = type.getSymbol()?.getName();
|
|
@@ -13920,7 +13924,7 @@ var ZodSchemaConverter = class {
|
|
|
13920
13924
|
return helperName.startsWith("coerce.") || helperName === "templateLiteral" || helperName === "stringbool";
|
|
13921
13925
|
}
|
|
13922
13926
|
if (t11.isMemberExpression(node.callee) && t11.isIdentifier(node.callee.property)) {
|
|
13923
|
-
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"
|
|
13927
|
+
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"]);
|
|
13924
13928
|
if (runtimeMethods.has(node.callee.property.name)) {
|
|
13925
13929
|
return true;
|
|
13926
13930
|
}
|
|
@@ -14097,15 +14101,13 @@ var ZodSchemaConverter = class {
|
|
|
14097
14101
|
schema.type = "integer";
|
|
14098
14102
|
break;
|
|
14099
14103
|
case "positive":
|
|
14100
|
-
schema.
|
|
14101
|
-
schema.exclusiveMinimum = true;
|
|
14104
|
+
schema.exclusiveMinimum = 0;
|
|
14102
14105
|
break;
|
|
14103
14106
|
case "nonnegative":
|
|
14104
14107
|
schema.minimum = 0;
|
|
14105
14108
|
break;
|
|
14106
14109
|
case "negative":
|
|
14107
|
-
schema.
|
|
14108
|
-
schema.exclusiveMaximum = true;
|
|
14110
|
+
schema.exclusiveMaximum = 0;
|
|
14109
14111
|
break;
|
|
14110
14112
|
case "nonpositive":
|
|
14111
14113
|
schema.maximum = 0;
|
|
@@ -17961,6 +17963,7 @@ function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
|
17961
17963
|
if (excludedNames.size === 0)
|
|
17962
17964
|
return;
|
|
17963
17965
|
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
17966
|
+
walkAndInline(mergedSchemas, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
17964
17967
|
for (const name of excludedNames) {
|
|
17965
17968
|
delete mergedSchemas[name];
|
|
17966
17969
|
}
|
|
@@ -12924,7 +12924,7 @@ var ZodSchemaConverter = class {
|
|
|
12924
12924
|
return helperName.startsWith("coerce.") || helperName === "templateLiteral" || helperName === "stringbool";
|
|
12925
12925
|
}
|
|
12926
12926
|
if (t10.isMemberExpression(node.callee) && t10.isIdentifier(node.callee.property)) {
|
|
12927
|
-
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"
|
|
12927
|
+
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"]);
|
|
12928
12928
|
if (runtimeMethods.has(node.callee.property.name)) {
|
|
12929
12929
|
return true;
|
|
12930
12930
|
}
|
|
@@ -13101,15 +13101,13 @@ var ZodSchemaConverter = class {
|
|
|
13101
13101
|
schema.type = "integer";
|
|
13102
13102
|
break;
|
|
13103
13103
|
case "positive":
|
|
13104
|
-
schema.
|
|
13105
|
-
schema.exclusiveMinimum = true;
|
|
13104
|
+
schema.exclusiveMinimum = 0;
|
|
13106
13105
|
break;
|
|
13107
13106
|
case "nonnegative":
|
|
13108
13107
|
schema.minimum = 0;
|
|
13109
13108
|
break;
|
|
13110
13109
|
case "negative":
|
|
13111
|
-
schema.
|
|
13112
|
-
schema.exclusiveMaximum = true;
|
|
13110
|
+
schema.exclusiveMaximum = 0;
|
|
13113
13111
|
break;
|
|
13114
13112
|
case "nonpositive":
|
|
13115
13113
|
schema.maximum = 0;
|
|
@@ -16965,6 +16963,7 @@ function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
|
16965
16963
|
if (excludedNames.size === 0)
|
|
16966
16964
|
return;
|
|
16967
16965
|
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16966
|
+
walkAndInline(mergedSchemas, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16968
16967
|
for (const name of excludedNames) {
|
|
16969
16968
|
delete mergedSchemas[name];
|
|
16970
16969
|
}
|
package/dist/vite/index.js
CHANGED
|
@@ -12924,7 +12924,7 @@ var ZodSchemaConverter = class {
|
|
|
12924
12924
|
return helperName.startsWith("coerce.") || helperName === "templateLiteral" || helperName === "stringbool";
|
|
12925
12925
|
}
|
|
12926
12926
|
if (t10.isMemberExpression(node.callee) && t10.isIdentifier(node.callee.property)) {
|
|
12927
|
-
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"
|
|
12927
|
+
const runtimeMethods = /* @__PURE__ */ new Set(["pipe"]);
|
|
12928
12928
|
if (runtimeMethods.has(node.callee.property.name)) {
|
|
12929
12929
|
return true;
|
|
12930
12930
|
}
|
|
@@ -13101,15 +13101,13 @@ var ZodSchemaConverter = class {
|
|
|
13101
13101
|
schema.type = "integer";
|
|
13102
13102
|
break;
|
|
13103
13103
|
case "positive":
|
|
13104
|
-
schema.
|
|
13105
|
-
schema.exclusiveMinimum = true;
|
|
13104
|
+
schema.exclusiveMinimum = 0;
|
|
13106
13105
|
break;
|
|
13107
13106
|
case "nonnegative":
|
|
13108
13107
|
schema.minimum = 0;
|
|
13109
13108
|
break;
|
|
13110
13109
|
case "negative":
|
|
13111
|
-
schema.
|
|
13112
|
-
schema.exclusiveMaximum = true;
|
|
13110
|
+
schema.exclusiveMaximum = 0;
|
|
13113
13111
|
break;
|
|
13114
13112
|
case "nonpositive":
|
|
13115
13113
|
schema.maximum = 0;
|
|
@@ -16965,6 +16963,7 @@ function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
|
16965
16963
|
if (excludedNames.size === 0)
|
|
16966
16964
|
return;
|
|
16967
16965
|
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16966
|
+
walkAndInline(mergedSchemas, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16968
16967
|
for (const name of excludedNames) {
|
|
16969
16968
|
delete mergedSchemas[name];
|
|
16970
16969
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-openapi-gen",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Automatically generate OpenAPI 3.0, 3.1, and 3.2 documentation from Next.js projects, with support for Zod schemas, TypeScript types, and reusable OpenAPI fragments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|