@tim-smart/openapi-gen 0.4.5 → 0.4.7
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/main.js +6 -7
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -34825,9 +34825,10 @@ var make64 = gen2(function* () {
|
|
|
34825
34825
|
const refStore = /* @__PURE__ */ new Map();
|
|
34826
34826
|
function cleanupSchema(schema) {
|
|
34827
34827
|
if ("type" in schema && Array.isArray(schema.type) && schema.type.includes("null")) {
|
|
34828
|
+
const type2 = schema.type.filter((_) => _ !== "null");
|
|
34828
34829
|
schema = {
|
|
34829
34830
|
...schema,
|
|
34830
|
-
type:
|
|
34831
|
+
type: type2.length === 1 ? type2[0] : type2,
|
|
34831
34832
|
nullable: true
|
|
34832
34833
|
};
|
|
34833
34834
|
}
|
|
@@ -34949,7 +34950,7 @@ var make64 = gen2(function* () {
|
|
|
34949
34950
|
if ("$ref" in raw) {
|
|
34950
34951
|
return refStore.get(raw.$ref) ?? raw;
|
|
34951
34952
|
}
|
|
34952
|
-
return raw;
|
|
34953
|
+
return cleanupSchema(raw);
|
|
34953
34954
|
};
|
|
34954
34955
|
const flattenAllOf = (schema) => {
|
|
34955
34956
|
if ("allOf" in schema) {
|
|
@@ -34968,9 +34969,6 @@ var make64 = gen2(function* () {
|
|
|
34968
34969
|
const transformer = yield* JsonSchemaTransformer;
|
|
34969
34970
|
const toSource = (importName, schema, currentIdentifier, topLevel = false) => {
|
|
34970
34971
|
schema = cleanupSchema(schema);
|
|
34971
|
-
if (currentIdentifier.startsWith("FunctionCall")) {
|
|
34972
|
-
console.error(schema, currentIdentifier);
|
|
34973
|
-
}
|
|
34974
34972
|
if ("properties" in schema) {
|
|
34975
34973
|
const obj = schema;
|
|
34976
34974
|
const required2 = obj.required ?? [];
|
|
@@ -34978,6 +34976,7 @@ var make64 = gen2(function* () {
|
|
|
34978
34976
|
Object.entries(obj.properties ?? {}),
|
|
34979
34977
|
filterMap2(([key, schema2]) => {
|
|
34980
34978
|
const fullSchema = getSchema(schema2);
|
|
34979
|
+
schema2 = cleanupSchema(schema2);
|
|
34981
34980
|
const isOptional = !required2.includes(key);
|
|
34982
34981
|
const [enumNullable, filteredSchema] = filterNullable(fullSchema);
|
|
34983
34982
|
return toSource(
|
|
@@ -35121,7 +35120,7 @@ var make64 = gen2(function* () {
|
|
|
35121
35120
|
return some2(transformer.onBoolean({ importName }));
|
|
35122
35121
|
}
|
|
35123
35122
|
case "array": {
|
|
35124
|
-
const nonEmpty = typeof schema.minItems === "number" && schema.minItems
|
|
35123
|
+
const nonEmpty = typeof schema.minItems === "number" && schema.minItems > 0;
|
|
35125
35124
|
return toSource(
|
|
35126
35125
|
importName,
|
|
35127
35126
|
itemsSchema(schema.items),
|
|
@@ -35261,7 +35260,7 @@ var layerTransformerSchema = sync6(JsonSchemaTransformer, () => {
|
|
|
35261
35260
|
},
|
|
35262
35261
|
onArray({ importName, schema, item, nonEmpty }) {
|
|
35263
35262
|
const modifiers = [];
|
|
35264
|
-
if ("minItems" in schema &&
|
|
35263
|
+
if ("minItems" in schema && nonEmpty) {
|
|
35265
35264
|
modifiers.push(`${importName}.minItems(${schema.minItems})`);
|
|
35266
35265
|
}
|
|
35267
35266
|
if ("maxItems" in schema) {
|