Skip to content

Commit

Permalink
fix: handle nested allOf (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
vwong authored Aug 21, 2023
1 parent c77c523 commit 41cb25d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import { traverseJsonSchema } from '../common/traverse-json-schema';
import { ParsedMockInteraction } from '../mock-parser/parsed-mock';
import { result } from '../result';
import { ParsedSpecJsonSchema, ParsedSpecJsonSchemaValue, ParsedSpecResponse } from '../spec-parser/parsed-spec';
import { ParsedSpecJsonSchema, ParsedSpecJsonSchemaCore, ParsedSpecResponse } from '../spec-parser/parsed-spec';
import { ValidateOptions } from '../types';
import { isTypesOfJson } from './content-negotiation';
import { validateJson } from './validate-json';
Expand Down Expand Up @@ -43,8 +43,12 @@ const transformSchema = (
// In draft 2019-09, JSON-Schema added "unevaluatedProperties" to support this behaviour
traverseJsonSchema(modifiedSchema, (mutableSchema) => {
if (mutableSchema.allOf) {
mutableSchema.allOf.forEach((s) => {
delete (s as ParsedSpecJsonSchemaValue).additionalProperties;
mutableSchema.allOf.forEach((s: ParsedSpecJsonSchemaCore) => {
delete s.additionalProperties;
if (s.allOf) {
// traversal is depth-first; if nested allOf, remove unevaluatedProperties from previously set deeper schema
delete s.unevaluatedProperties;
}
});
mutableSchema.unevaluatedProperties = false;
}
Expand Down

0 comments on commit 41cb25d

Please sign in to comment.