Skip to content

Commit

Permalink
fix: incorrect dotted property parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluard committed Dec 19, 2023
1 parent 7787236 commit 25e8aa5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/api/test/utils/checkAgainstSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function deleteNested(schema: JsonSchema | undefined, property: string): void {
const properties = schema?.properties;
if (property.includes(".")) {
// Extract first segment, keep the rest as dotted
const [key, rest] = property.split(".", 2);
deleteNested(properties?.[key], rest);
const [key, ...rest] = property.split(".");
deleteNested(properties?.[key], rest.join("."));
} else {
// Remove property from 'required'
if (schema?.required) {
Expand Down Expand Up @@ -123,7 +123,9 @@ export function runTestCheckAgainstSpec(
const ignoredProperties = ignoredProperty?.request;
if (ignoredProperties) {
// Remove ignored properties from schema validation
ignoredProperties.forEach((property) => deleteNested(routeSpec.requestSchema, property));
for (const property of ignoredProperties) {
deleteNested(routeSpec.requestSchema, property);
}
}

// Validate request
Expand All @@ -148,7 +150,9 @@ export function runTestCheckAgainstSpec(
const ignoredProperties = ignoredProperty?.response;
if (ignoredProperties) {
// Remove ignored properties from schema validation
ignoredProperties.forEach((property) => deleteNested(routeSpec.responseOkSchema, property));
for (const property of ignoredProperties) {
deleteNested(routeSpec.responseOkSchema, property);
}
}
// Validate response
validateSchema(responseOkSchema, resJson, "response");
Expand Down

0 comments on commit 25e8aa5

Please sign in to comment.