Validate empty Swagger property names - #2343
Conversation
Signed-off-by: king-407 <95581750+king-407@users.noreply.github.com>
|
Thanks for the fix and the regression test! The OpenAPI 2.0 Schema Object applies JSON Schema semantics to properties. JSON Schema Draft 4 requires properties to be an object where each value is a valid schema, but says nothing about the names being non-empty. The official OpenAPI 2.0 validation schema has no such restriction either. Duplicate names are a separate problem. RFC 8259 recommends unique names and warns that behavior is unpredictable otherwise, but by the time SwaggerConverter receives a Map<String, Property>, duplicates have already been collapsed. A converter traversal can't reliably detect that data loss. Emitting a warning here would flag spec-valid documents as broken and could cause consumers that treat parser messages as errors to reject those documents. We're closing this without merging. Thanks again for digging into this! |
Fixes #2339.
What changed
This adds validation for Swagger 2.0 schemas that contain an empty property name under
properties.Previously, a schema like this was parsed without reporting a validation message:
The converter now adds a validation message for the empty property name while continuing to parse the document.
Testing
Ran the focused regression test and the full
V2ConverterTestclass: