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.cjs
CHANGED
|
@@ -1570,6 +1570,15 @@ var ParamResolver = class extends ParamResolverBase {
|
|
|
1570
1570
|
}
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
|
+
handleResolveValue(v) {
|
|
1574
|
+
if (this.info?.required && v == null) {
|
|
1575
|
+
throw new BlankReturnMessageDto(
|
|
1576
|
+
400,
|
|
1577
|
+
`Required parameter '${this.info.paramName}' in ${this.info.paramType} is missing`
|
|
1578
|
+
).toException();
|
|
1579
|
+
}
|
|
1580
|
+
return v;
|
|
1581
|
+
}
|
|
1573
1582
|
resolve(req, ref) {
|
|
1574
1583
|
if (this.info) {
|
|
1575
1584
|
if (this.info.paramType === "header") {
|
|
@@ -1577,10 +1586,10 @@ var ParamResolver = class extends ParamResolverBase {
|
|
|
1577
1586
|
let raw = getHeader(req, name);
|
|
1578
1587
|
if (name === "accept-language")
|
|
1579
1588
|
raw = pickPrimaryFromAcceptLanguage(raw);
|
|
1580
|
-
return raw;
|
|
1589
|
+
return this.handleResolveValue(raw);
|
|
1581
1590
|
}
|
|
1582
1591
|
if (this.info.paramType === "query") {
|
|
1583
|
-
return getQueryValue(req, this.info.paramName);
|
|
1592
|
+
return this.handleResolveValue(getQueryValue(req, this.info.paramName));
|
|
1584
1593
|
}
|
|
1585
1594
|
throw new Error(`Unsupported paramType: ${this.info.paramType}`);
|
|
1586
1595
|
} else if (this.dynamic) {
|
|
@@ -1616,7 +1625,13 @@ var ParamResolver = class extends ParamResolverBase {
|
|
|
1616
1625
|
{
|
|
1617
1626
|
swagger,
|
|
1618
1627
|
token: this.toString()
|
|
1619
|
-
}
|
|
1628
|
+
},
|
|
1629
|
+
...this.info?.required ? [
|
|
1630
|
+
{
|
|
1631
|
+
swagger: () => ApiError(400, "Invalid request parameters"),
|
|
1632
|
+
token: `__missing_required_400__`
|
|
1633
|
+
}
|
|
1634
|
+
] : []
|
|
1620
1635
|
];
|
|
1621
1636
|
}
|
|
1622
1637
|
};
|