Skip to content

Commit

Permalink
Cleanup object check (remove tautology, verboseness)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLey committed Dec 17, 2019
1 parent 8a159f3 commit 74a0149
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/middlewares/openapi.request.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,15 @@ export class RequestValidator {
}
} else if ($in === 'query') {
// handle complex json types in schema
const schemaHasObject = schema => {
return (
schema.type === 'object' &&
schema.type !== 'array'
) || (
schema.allOf &&
schema.allOf.some(schemaHasObject)
) || (
schema.oneOf &&
schema.oneOf.some(schemaHasObject)
) || (
schema.anyOf &&
schema.anyOf.some(schemaHasObject)
)
};
const schemaHasObject = schema =>
schema && (
schema.type === 'object' ||
[].concat(
schema.allOf,
schema.oneOf,
schema.anyOf,
).some(schemaHasObject)
);

if (schemaHasObject(parameterSchema)) {
parseJson.push({ name, reqField });
Expand Down

0 comments on commit 74a0149

Please sign in to comment.