adorn-api 1.1.8 → 1.1.9
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/adapter/express/coercion.js +14 -2
- package/dist/core/openapi.js +23 -7
- package/package.json +1 -1
|
@@ -136,8 +136,20 @@ function coerceArrayValue(value, schema, mode) {
|
|
|
136
136
|
if (value === undefined || value === null) {
|
|
137
137
|
return { value, ok: true, changed: false };
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
let changed
|
|
139
|
+
let input;
|
|
140
|
+
let changed;
|
|
141
|
+
if (Array.isArray(value)) {
|
|
142
|
+
input = value;
|
|
143
|
+
changed = false;
|
|
144
|
+
}
|
|
145
|
+
else if (typeof value === "string" && value.includes(",")) {
|
|
146
|
+
input = value.split(",").map((s) => s.trim());
|
|
147
|
+
changed = true;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
input = [value];
|
|
151
|
+
changed = true;
|
|
152
|
+
}
|
|
141
153
|
let ok = true;
|
|
142
154
|
const output = input.map((entry) => {
|
|
143
155
|
const result = coerceValue(entry, schema.items, mode);
|
package/dist/core/openapi.js
CHANGED
|
@@ -216,13 +216,29 @@ function buildParameters(location, input, context) {
|
|
|
216
216
|
if (!fieldEntries.length) {
|
|
217
217
|
return [];
|
|
218
218
|
}
|
|
219
|
-
return fieldEntries.map((entry) =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
return fieldEntries.map((entry) => {
|
|
220
|
+
const param = {
|
|
221
|
+
name: entry.name,
|
|
222
|
+
in: location,
|
|
223
|
+
required: location === "path" ? true : entry.required,
|
|
224
|
+
description: entry.description,
|
|
225
|
+
schema: (0, schema_builder_1.buildSchemaFromSource)(entry.schema, context)
|
|
226
|
+
};
|
|
227
|
+
if (location === "query" && isSchemaNode(entry.schema)) {
|
|
228
|
+
if (entry.schema.kind === "array") {
|
|
229
|
+
param.style = "form";
|
|
230
|
+
param.explode = true;
|
|
231
|
+
}
|
|
232
|
+
else if (entry.schema.kind === "object") {
|
|
233
|
+
param.style = "deepObject";
|
|
234
|
+
param.explode = true;
|
|
235
|
+
}
|
|
236
|
+
if (entry.schema.examples && entry.schema.examples.length > 0) {
|
|
237
|
+
param.example = entry.schema.examples[0];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return param;
|
|
241
|
+
});
|
|
226
242
|
}
|
|
227
243
|
function extractFields(schema) {
|
|
228
244
|
if (isSchemaNode(schema)) {
|