Spaces:
Running
Running
Commit
·
411c3a4
1
Parent(s):
d45c8c7
fix: swagger request array types
Browse files
src/lib/decorators/swagger-request.decorator.ts
CHANGED
@@ -7,12 +7,26 @@ const parseToSchema = (schema: any, joiSchema: any) => {
|
|
7 |
properties.forEach((property) => {
|
8 |
const type = joiSchema[property].type;
|
9 |
if (type === "array") {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
} else if (type === "object") {
|
17 |
schema.properties[property] = {
|
18 |
type: "object",
|
|
|
7 |
properties.forEach((property) => {
|
8 |
const type = joiSchema[property].type;
|
9 |
if (type === "array") {
|
10 |
+
const at = joiSchema[property].items[0].type;
|
11 |
+
// recursively parse array
|
12 |
+
if (at === "object" || at === "array") {
|
13 |
+
schema.properties[property] = {
|
14 |
+
type: "array",
|
15 |
+
items: {
|
16 |
+
type: "object",
|
17 |
+
properties: {},
|
18 |
+
},
|
19 |
+
};
|
20 |
+
parseToSchema(schema.properties[property].items, joiSchema[property].items[0]);
|
21 |
+
} else {
|
22 |
+
schema.properties[property] = {
|
23 |
+
type: "array",
|
24 |
+
items: {
|
25 |
+
type: at,
|
26 |
+
},
|
27 |
+
};
|
28 |
+
}
|
29 |
+
|
30 |
} else if (type === "object") {
|
31 |
schema.properties[property] = {
|
32 |
type: "object",
|