Repository navigation
fix(validations): include properties segment in ValidateSchemaPropertyHasValue pointer - #3165
Conversation
…yHasValue pointer Enter the properties segment before property.Key when validating that schema properties have values so the generated error JSON pointer conforms to RFC 6901 and correctly navigates to the property within the schema object. Signed-off-by: Hardik K <[email protected]>
…egment in error pointer Update the expected JSON pointer in ValidateNullProperty from #/schemas/schema1/property1 to #/schemas/schema1/properties/property1 to verify that the properties navigation segment is included in the error pointer. Signed-off-by: Hardik K <[email protected]>
…pointer Add unit test ValidateSchemaPropertyHasValueShouldReportErrorWithPropertiesPath verifying that validating a standalone schema with a null property produces an error pointer anchored at #/properties/name. Signed-off-by: Hardik K <[email protected]>
…rror pointers Add ValidateSchemaPropertyHasValueWithMultipleNullPropertiesShouldIncludePropertiesSegmentForEach to verify that each null property in a schema receives its own error pointer with the properties path segment. Signed-off-by: Hardik K <[email protected]>
…ation response property pointers Add integration tests verifying full JSON pointer accuracy for null schema properties inside document components (#/components/schemas/User/properties/nullProp) and nested under operation responses (#/paths/~1items/get/responses/200/content/application~1json/schema/properties/missingSchema). Signed-off-by: Hardik K <[email protected]>
…maPropertyHasValue Update XML doc comments on ValidateSchemaPropertyHasValue to explain that error pointers include the properties segment under RFC 6901 / JSON Schema conventions. Signed-off-by: Hardik K <[email protected]>
|
Following up on the pointer accuracy discussion noted in #2806, I noticed As a result, validation error pointers for null schema properties omitted the This PR wraps the error generation with Whenever you have some time to take a look, I'd appreciate your feedback. Thanks! |
Summary
When validating that schema properties have non-null values,
OpenApiSchemaRules.ValidateSchemaPropertyHasValueenters each property key (context.Enter(property.Key)) directly without first entering thepropertiessegment (OpenApiConstants.Properties).This caused the resulting
OpenApiValidatorError.Pointerto omit thepropertiesnavigation segment (for example, generating#/schemas/schema1/property1instead of#/schemas/schema1/properties/property1, or#/components/schemas/User/nullPropinstead of#/components/schemas/User/properties/nullProp). In RFC 6901 JSON Pointers and OpenAPI/JSON Schema models, properties must be indexed under/properties/{propertyName}.Changes
OpenApiSchemaRules.ValidateSchemaPropertyHasValue, enteredOpenApiConstants.Propertiesbefore enteringproperty.Key(and exited both accordingly).ValidateNullPropertytest to verify the corrected pointer path#/schemas/schema1/properties/property1.ValidateSchemaPropertyHasValue.Verification
dotnet test), all 1963 tests across the solution pass.