Skip to content

Commit 313793f

Browse files
authored
Merge pull request #2365 from blackflux/dev
[Gally]: master <- dev
2 parents 771623c + 3a643f9 commit 313793f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ Takes the following positional arguments:
9191

9292
Note: The (slightly modified) original event and context can be accessed as additional handler parameters
9393

94+
### Endpoint Options
95+
96+
- _limit_: ...
97+
- _deprecated_: ...
98+
- _versioning_: ...
99+
- _logSuccess_: ...
100+
- _logError_: ...
101+
- _allowUnknownJson_ (default `false`): Allow unknown json body parameters
102+
94103
## Api Parameters
95104

96105
There are various pre-defined parameters available

src/logic/wrapper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export const Wrapper = ({ router, module }) => {
2525
}).optional(),
2626
versioning: Joi.boolean().optional(),
2727
logSuccess: Joi.boolean().optional(),
28-
logError: Joi.boolean().optional()
28+
logError: Joi.boolean().optional(),
29+
allowUnknownJson: Joi.boolean().optional()
2930
}).optional());
3031
assert(typeof handler === 'function');
3132

src/plugin/validator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Validator extends Plugin {
9191
Object.keys(event.body || {}),
9292
request.params.filter((p) => p.position === 'json').map((p) => p.name)
9393
);
94-
if (invalidJsonParams.length !== 0) {
94+
if (invalidJsonParams.length !== 0 && request?.options?.allowUnknownJson !== true) {
9595
throw ApiErrorFn('Invalid Json Body Param(s) detected.', 400, 99005, {
9696
value: invalidJsonParams
9797
});

0 commit comments

Comments
 (0)