nesties 1.1.20 → 1.1.21
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/index.cjs +18 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +18 -3
- package/dist/index.mjs.map +2 -2
- package/dist/src/resolver.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1523,6 +1523,15 @@ var ParamResolver = class extends ParamResolverBase {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
1525
|
}
|
|
1526
|
+
handleResolveValue(v) {
|
|
1527
|
+
if (this.info?.required && v == null) {
|
|
1528
|
+
throw new BlankReturnMessageDto(
|
|
1529
|
+
400,
|
|
1530
|
+
`Required parameter '${this.info.paramName}' in ${this.info.paramType} is missing`
|
|
1531
|
+
).toException();
|
|
1532
|
+
}
|
|
1533
|
+
return v;
|
|
1534
|
+
}
|
|
1526
1535
|
resolve(req, ref) {
|
|
1527
1536
|
if (this.info) {
|
|
1528
1537
|
if (this.info.paramType === "header") {
|
|
@@ -1530,10 +1539,10 @@ var ParamResolver = class extends ParamResolverBase {
|
|
|
1530
1539
|
let raw = getHeader(req, name);
|
|
1531
1540
|
if (name === "accept-language")
|
|
1532
1541
|
raw = pickPrimaryFromAcceptLanguage(raw);
|
|
1533
|
-
return raw;
|
|
1542
|
+
return this.handleResolveValue(raw);
|
|
1534
1543
|
}
|
|
1535
1544
|
if (this.info.paramType === "query") {
|
|
1536
|
-
return getQueryValue(req, this.info.paramName);
|
|
1545
|
+
return this.handleResolveValue(getQueryValue(req, this.info.paramName));
|
|
1537
1546
|
}
|
|
1538
1547
|
throw new Error(`Unsupported paramType: ${this.info.paramType}`);
|
|
1539
1548
|
} else if (this.dynamic) {
|
|
@@ -1569,7 +1578,13 @@ var ParamResolver = class extends ParamResolverBase {
|
|
|
1569
1578
|
{
|
|
1570
1579
|
swagger,
|
|
1571
1580
|
token: this.toString()
|
|
1572
|
-
}
|
|
1581
|
+
},
|
|
1582
|
+
...this.info?.required ? [
|
|
1583
|
+
{
|
|
1584
|
+
swagger: () => ApiError(400, "Invalid request parameters"),
|
|
1585
|
+
token: `__missing_required_400__`
|
|
1586
|
+
}
|
|
1587
|
+
] : []
|
|
1573
1588
|
];
|
|
1574
1589
|
}
|
|
1575
1590
|
};
|