@trojs/openapi-server 1.4.0 → 1.5.0
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/package.json +1 -1
- package/src/params.js +7 -6
package/package.json
CHANGED
package/src/params.js
CHANGED
|
@@ -11,16 +11,16 @@ export const parseParams = ({ query, spec }) =>
|
|
|
11
11
|
spec
|
|
12
12
|
.map((parameter) => {
|
|
13
13
|
const { name, schema } = parameter;
|
|
14
|
-
const {
|
|
15
|
-
type,
|
|
16
|
-
default: defaultValue,
|
|
17
|
-
example: exampleValue,
|
|
18
|
-
} = schema;
|
|
14
|
+
const { type, default: defaultValue } = schema;
|
|
19
15
|
const Type = types[type];
|
|
20
16
|
const paramName = query?.[name];
|
|
21
17
|
|
|
18
|
+
if (!paramName && defaultValue) {
|
|
19
|
+
return { name, value: defaultValue };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
22
|
if (!paramName) {
|
|
23
|
-
return
|
|
23
|
+
return undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (Type === Boolean) {
|
|
@@ -33,6 +33,7 @@ export const parseParams = ({ query, spec }) =>
|
|
|
33
33
|
const value = new Type(paramName).valueOf();
|
|
34
34
|
return { name, value };
|
|
35
35
|
})
|
|
36
|
+
.filter(Boolean)
|
|
36
37
|
.reduce((acc, { name, value }) => {
|
|
37
38
|
acc[name] = value;
|
|
38
39
|
return acc;
|