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.
@@ -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
- const input = Array.isArray(value) ? value : [value];
140
- let changed = !Array.isArray(value);
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);
@@ -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
- name: entry.name,
221
- in: location,
222
- required: location === "path" ? true : entry.required,
223
- description: entry.description,
224
- schema: (0, schema_builder_1.buildSchemaFromSource)(entry.schema, context)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adorn-api",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Decorator-first web framework with OpenAPI 3.1 schema generation.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",