Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdbosch committed Jan 9, 2025
1 parent e269712 commit 569b906
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,24 @@ public static List<String> getUndefinedProperties(ExampleDefinition exampleDefin
// Properties are only considered as undefined when additionalProperties are not explicitly allowed in the schema
// if additionalProperties is false, example schema validation will mark any undefined properties as invalid, so can be ignored here

// TODO: composite with additional properties? What if in nested object only? - move to fromObjectNode?
// TODO: what if composite schema with additional properties in subschema?
/**
* MySchema:
* type: object
* allOf:
* - additionalProperties: true
* - someProperty:
* type: integer
*/
// TODO: What if additional properties set in nested object? - move to fromObjectNode?
/**
* MySchema:
* type: object
* properties:
* someProperty:
* type: object
* additionalProperties: true
*/
return new ArrayList<>();
}
return getUndefinedProperties(exampleNode, schemaDefinition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ global io.github.belgif.rest.guide.validator.core.parser.Parser.ParserResult par

function void violationExamplesShouldValidateAgainstSchema(ViolationReport oas, ExampleDefinition example, String violation){
oas.addViolation("[oas-exampl]",
"Example does not validate against schema", violation, example);
"Example must be schema-valid and shouldn't have undefined properties", violation, example);
}

function void violationExamplesShouldNotHaveUndefinedProperties(ViolationReport oas, ExampleDefinition example, String violation) {
oas.addViolation("[oas-exampl]",
"Example shouldn't contain undefined property", violation, example, ViolationLevel.RECOMMENDED);
"Example must be schema-valid and shouldn't have undefined properties", violation, example, ViolationLevel.RECOMMENDED);
}

rule "Example should be valid against schema"
Expand Down

0 comments on commit 569b906

Please sign in to comment.