Repository navigation
Lint the example keyword in OpenAPI schema objects - #926
Conversation
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
🤖 Augment PR SummarySummary: Adds linting to catch OpenAPI schema examples that fail validation. 🤖 Was this summary useful? React with 👍 or 👎 |
| ONLY_CONTINUE_IF(!schema.defines("$ref")); | ||
| } | ||
|
|
||
| const auto &instance{schema.at("example")}; |
There was a problem hiding this comment.
At vendor/blaze/src/alterschema/linter/valid_example.h:29, could you check an XML example such as {"type":"object","example":"<pet/>"}? OpenAPI 3.0 explicitly permits string-encoded non-JSON examples, but this value is passed unchanged to JSON validation, so lint flags it as a type mismatch and --fix deletes a permitted example.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| const auto result{evaluator.validate(schema_template.value(), instance, | ||
| std::ref(output))}; |
There was a problem hiding this comment.
At vendor/blaze/src/alterschema/linter/valid_example.h:73–74, could you check an OpenAPI 3.0 request schema with required: [id], properties: {id: {type: integer, readOnly: true}}, and example: {}? That example is valid because the requirement applies only to responses, but the compiler ignores readOnly and enforces every required entry, causing lint to reject it and --fix to delete it; response examples omitting required writeOnly fields have the same problem.
Other locations where this applies: vendor/blaze/src/alterschema/linter/valid_example.h:47–48
Severity: medium
Other Locations
vendor/blaze/src/alterschema/linter/valid_example.h:47
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Signed-off-by: Juan Cruz Viotti jv@jviotti.com