adorn-api 1.1.8 → 1.1.10
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.
|
@@ -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)) {
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export async function createExpressApp(options: ExpressAdapterOptions): Promise<
|
|
|
21
21
|
attachCors(app, options.cors === true ? {} : options.cors);
|
|
22
22
|
}
|
|
23
23
|
if (options.jsonBody ?? true) {
|
|
24
|
-
app.use(express.json());
|
|
24
|
+
app.use(express.json({ limit: options.jsonLimit }));
|
|
25
25
|
}
|
|
26
26
|
const inputCoercion = options.inputCoercion ?? "safe";
|
|
27
27
|
await attachControllers(app, options.controllers, inputCoercion, options.multipart, options.validation);
|
|
@@ -145,6 +145,8 @@ export interface ExpressAdapterOptions {
|
|
|
145
145
|
controllers: Constructor[];
|
|
146
146
|
/** Whether to enable JSON body parsing */
|
|
147
147
|
jsonBody?: boolean;
|
|
148
|
+
/** Max JSON body size (e.g. "50mb"). Defaults to Express's "100kb". */
|
|
149
|
+
jsonLimit?: string;
|
|
148
150
|
/** OpenAPI configuration */
|
|
149
151
|
openApi?: OpenApiExpressOptions;
|
|
150
152
|
/** Input coercion setting */
|