@tim-smart/openapi-gen 0.3.9 → 0.3.11
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 +76 -21
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -29969,27 +29969,21 @@ var make63 = gen2(function* () {
|
|
|
29969
29969
|
const addSchema = (name, root2, context7, asStruct = false) => {
|
|
29970
29970
|
function addRefs(schema, childName, asStruct2 = true) {
|
|
29971
29971
|
if ("$ref" in schema) {
|
|
29972
|
-
|
|
29972
|
+
const resolved = resolveRef(schema, {
|
|
29973
|
+
...root2,
|
|
29974
|
+
...context7
|
|
29975
|
+
});
|
|
29976
|
+
if (!resolved) {
|
|
29973
29977
|
return;
|
|
29974
29978
|
}
|
|
29975
|
-
|
|
29976
|
-
const name2 = identifier2(path2[path2.length - 1]);
|
|
29977
|
-
if (store.has(name2)) {
|
|
29979
|
+
if (store.has(resolved.name)) {
|
|
29978
29980
|
return;
|
|
29979
29981
|
}
|
|
29980
|
-
|
|
29981
|
-
|
|
29982
|
-
|
|
29983
|
-
};
|
|
29984
|
-
for (const key of path2) {
|
|
29985
|
-
if (!current) return;
|
|
29986
|
-
current = current[key];
|
|
29987
|
-
}
|
|
29988
|
-
refStore.set(schema.$ref, current);
|
|
29989
|
-
addRefs(current, name2);
|
|
29990
|
-
store.set(name2, current);
|
|
29982
|
+
refStore.set(schema.$ref, resolved.schema);
|
|
29983
|
+
addRefs(resolved.schema, resolved.name);
|
|
29984
|
+
store.set(resolved.name, resolved.schema);
|
|
29991
29985
|
if (!asStruct2) {
|
|
29992
|
-
classes.add(
|
|
29986
|
+
classes.add(resolved.name);
|
|
29993
29987
|
}
|
|
29994
29988
|
} else if ("properties" in schema) {
|
|
29995
29989
|
Object.entries(schema.properties).forEach(
|
|
@@ -30002,9 +29996,22 @@ var make63 = gen2(function* () {
|
|
|
30002
29996
|
addRefs(schema.items, void 0);
|
|
30003
29997
|
}
|
|
30004
29998
|
} else if ("allOf" in schema) {
|
|
30005
|
-
schema.allOf.
|
|
30006
|
-
|
|
30007
|
-
|
|
29999
|
+
if (schema.allOf.length === 1) {
|
|
30000
|
+
const resolved = { ...schema, ...schema.allOf[0] };
|
|
30001
|
+
delete resolved.allOf;
|
|
30002
|
+
addRefs(resolved, childName, asStruct2);
|
|
30003
|
+
} else {
|
|
30004
|
+
const resolved = resolveAllOf(schema, {
|
|
30005
|
+
...root2,
|
|
30006
|
+
...context7
|
|
30007
|
+
});
|
|
30008
|
+
if (childName !== void 0) {
|
|
30009
|
+
addRefs(resolved, childName + "Enum", asStruct2);
|
|
30010
|
+
store.set(childName, resolved);
|
|
30011
|
+
} else {
|
|
30012
|
+
addRefs(resolved, void 0, asStruct2);
|
|
30013
|
+
}
|
|
30014
|
+
}
|
|
30008
30015
|
} else if ("anyOf" in schema) {
|
|
30009
30016
|
schema.anyOf.forEach(
|
|
30010
30017
|
(s) => addRefs(s, childName ? childName + "Enum" : void 0)
|
|
@@ -30037,7 +30044,7 @@ var make63 = gen2(function* () {
|
|
|
30037
30044
|
const isEnum = enums.has(name);
|
|
30038
30045
|
return toSource(S, schema, name, isClass || isEnum).pipe(
|
|
30039
30046
|
map2((source) => {
|
|
30040
|
-
const isObject2 = "properties" in schema
|
|
30047
|
+
const isObject2 = "properties" in schema;
|
|
30041
30048
|
if (!isObject2 || !isClass) {
|
|
30042
30049
|
return `export class ${name} extends ${source} {}`;
|
|
30043
30050
|
}
|
|
@@ -30175,6 +30182,9 @@ var make63 = gen2(function* () {
|
|
|
30175
30182
|
topLevel
|
|
30176
30183
|
);
|
|
30177
30184
|
} else if ("allOf" in schema) {
|
|
30185
|
+
if (store.has(currentIdentifier)) {
|
|
30186
|
+
return some2(currentIdentifier);
|
|
30187
|
+
}
|
|
30178
30188
|
const sources = schema.allOf;
|
|
30179
30189
|
if (sources.length === 0) {
|
|
30180
30190
|
return none2();
|
|
@@ -30245,12 +30255,56 @@ function mergeSchemas(self, other) {
|
|
|
30245
30255
|
},
|
|
30246
30256
|
required: [...other.required || [], ...self.required || []]
|
|
30247
30257
|
};
|
|
30258
|
+
} else if ("anyOf" in self && "anyOf" in other) {
|
|
30259
|
+
return {
|
|
30260
|
+
...other,
|
|
30261
|
+
...self,
|
|
30262
|
+
anyOf: [...self.anyOf, ...other.anyOf]
|
|
30263
|
+
};
|
|
30248
30264
|
}
|
|
30249
30265
|
return {
|
|
30250
30266
|
...self,
|
|
30251
30267
|
...other
|
|
30252
30268
|
};
|
|
30253
30269
|
}
|
|
30270
|
+
function resolveAllOf(schema, context7, resolveRefs = true) {
|
|
30271
|
+
if ("$ref" in schema) {
|
|
30272
|
+
const resolved = resolveRef(schema, context7, resolveRefs);
|
|
30273
|
+
if (!resolved) {
|
|
30274
|
+
return schema;
|
|
30275
|
+
}
|
|
30276
|
+
return resolved.schema;
|
|
30277
|
+
} else if ("allOf" in schema) {
|
|
30278
|
+
if (schema.allOf.length <= 1) {
|
|
30279
|
+
let out2 = { ...schema };
|
|
30280
|
+
delete out2.allOf;
|
|
30281
|
+
if (schema.allOf.length === 0) {
|
|
30282
|
+
return out2;
|
|
30283
|
+
}
|
|
30284
|
+
Object.assign(out2, schema.allOf[0]);
|
|
30285
|
+
return resolveAllOf(out2, context7, resolveRefs);
|
|
30286
|
+
}
|
|
30287
|
+
let out = {};
|
|
30288
|
+
for (const member of schema.allOf) {
|
|
30289
|
+
out = mergeSchemas(out, resolveAllOf(member, context7, resolveRefs));
|
|
30290
|
+
}
|
|
30291
|
+
return out;
|
|
30292
|
+
}
|
|
30293
|
+
return schema;
|
|
30294
|
+
}
|
|
30295
|
+
function resolveRef(schema, context7, recursive = false) {
|
|
30296
|
+
if (!schema.$ref.startsWith("#")) {
|
|
30297
|
+
return;
|
|
30298
|
+
}
|
|
30299
|
+
const path2 = schema.$ref.slice(2).split("/");
|
|
30300
|
+
const name = identifier2(path2[path2.length - 1]);
|
|
30301
|
+
let current = context7;
|
|
30302
|
+
for (const key of path2) {
|
|
30303
|
+
if (!current) return;
|
|
30304
|
+
current = current[key];
|
|
30305
|
+
}
|
|
30306
|
+
return { name, schema: resolveAllOf(current, context7, recursive) };
|
|
30307
|
+
}
|
|
30254
30308
|
|
|
30255
30309
|
// src/OpenApi.ts
|
|
30256
30310
|
var methodNames = [
|
|
@@ -30369,6 +30423,7 @@ var make64 = gen2(function* () {
|
|
|
30369
30423
|
'import * as HttpClientError from "@effect/platform/HttpClientError"',
|
|
30370
30424
|
'import * as HttpClientRequest from "@effect/platform/HttpClientRequest"',
|
|
30371
30425
|
'import * as HttpClientResponse from "@effect/platform/HttpClientResponse"',
|
|
30426
|
+
'import * as UrlParams from "@effect/platform/UrlParams"',
|
|
30372
30427
|
'import * as Effect from "effect/Effect"',
|
|
30373
30428
|
'import type { ParseError } from "effect/ParseResult"',
|
|
30374
30429
|
'import * as S from "effect/Schema"'
|
|
@@ -30474,7 +30529,7 @@ var operationToImpl = (operation) => {
|
|
|
30474
30529
|
const varName = operation.payload ? "options.params" : "options";
|
|
30475
30530
|
if (operation.urlParams.length > 0) {
|
|
30476
30531
|
const props = operation.urlParams.map(
|
|
30477
|
-
(param) => `"${param}": ${varName}["${param}"]`
|
|
30532
|
+
(param) => `"${param}": ${varName}["${param}"] as UrlParams.Coercible`
|
|
30478
30533
|
);
|
|
30479
30534
|
pipeline.push(`HttpClientRequest.setUrlParams({ ${props.join(", ")} })`);
|
|
30480
30535
|
}
|