@treatwell/moleculer-essentials 1.2.1 → 1.2.2
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 +21 -8
- package/dist/index.mjs +21 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -224,13 +224,21 @@ function createOperationFromAlias(alias, extractor, url) {
|
|
|
224
224
|
const responses = {};
|
|
225
225
|
if (openapi.responses) {
|
|
226
226
|
for (const [key, val] of Object.entries(openapi.responses)) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
content
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
const res = { ...val };
|
|
228
|
+
if ("content" in res) {
|
|
229
|
+
res.content = { ...res.content };
|
|
230
|
+
let content = res.content["application/json"];
|
|
231
|
+
if (content) {
|
|
232
|
+
res.content["application/json"] = { ...content };
|
|
233
|
+
content = res.content["application/json"];
|
|
234
|
+
}
|
|
235
|
+
if (content && "zodInstance" in content && typeof content.zodInstance === "function") {
|
|
236
|
+
content.schema = index.zodToOpenAPISchema(content.zodInstance(), extractor);
|
|
237
|
+
} else if (content?.schema) {
|
|
238
|
+
content.schema = extractor.extract(content.schema);
|
|
239
|
+
}
|
|
233
240
|
}
|
|
241
|
+
responses[key] = res;
|
|
234
242
|
}
|
|
235
243
|
}
|
|
236
244
|
return {
|
|
@@ -332,8 +340,13 @@ function createOperationFromZodParams(params, pathParams, alias, extractor) {
|
|
|
332
340
|
Object.fromEntries(parameters.map((p) => [p.name, true]))
|
|
333
341
|
);
|
|
334
342
|
}
|
|
335
|
-
|
|
336
|
-
|
|
343
|
+
const { bodySchemaRefName } = alias.action;
|
|
344
|
+
if (bodySchemaRefName) {
|
|
345
|
+
if (v4.z.globalRegistry._idmap.has(bodySchemaRefName)) {
|
|
346
|
+
zodBody = v4.z.globalRegistry._idmap.get(bodySchemaRefName);
|
|
347
|
+
} else {
|
|
348
|
+
zodBody = zodBody.meta({ id: bodySchemaRefName });
|
|
349
|
+
}
|
|
337
350
|
}
|
|
338
351
|
requestBody = {
|
|
339
352
|
required: true,
|
package/dist/index.mjs
CHANGED
|
@@ -224,13 +224,21 @@ function createOperationFromAlias(alias, extractor, url) {
|
|
|
224
224
|
const responses = {};
|
|
225
225
|
if (openapi.responses) {
|
|
226
226
|
for (const [key, val] of Object.entries(openapi.responses)) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
content
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
const res = { ...val };
|
|
228
|
+
if ("content" in res) {
|
|
229
|
+
res.content = { ...res.content };
|
|
230
|
+
let content = res.content["application/json"];
|
|
231
|
+
if (content) {
|
|
232
|
+
res.content["application/json"] = { ...content };
|
|
233
|
+
content = res.content["application/json"];
|
|
234
|
+
}
|
|
235
|
+
if (content && "zodInstance" in content && typeof content.zodInstance === "function") {
|
|
236
|
+
content.schema = zodToOpenAPISchema(content.zodInstance(), extractor);
|
|
237
|
+
} else if (content?.schema) {
|
|
238
|
+
content.schema = extractor.extract(content.schema);
|
|
239
|
+
}
|
|
233
240
|
}
|
|
241
|
+
responses[key] = res;
|
|
234
242
|
}
|
|
235
243
|
}
|
|
236
244
|
return {
|
|
@@ -332,8 +340,13 @@ function createOperationFromZodParams(params, pathParams, alias, extractor) {
|
|
|
332
340
|
Object.fromEntries(parameters.map((p) => [p.name, true]))
|
|
333
341
|
);
|
|
334
342
|
}
|
|
335
|
-
|
|
336
|
-
|
|
343
|
+
const { bodySchemaRefName } = alias.action;
|
|
344
|
+
if (bodySchemaRefName) {
|
|
345
|
+
if (z.globalRegistry._idmap.has(bodySchemaRefName)) {
|
|
346
|
+
zodBody = z.globalRegistry._idmap.get(bodySchemaRefName);
|
|
347
|
+
} else {
|
|
348
|
+
zodBody = zodBody.meta({ id: bodySchemaRefName });
|
|
349
|
+
}
|
|
337
350
|
}
|
|
338
351
|
requestBody = {
|
|
339
352
|
required: true,
|