Skip to content

Lint the example keyword in OpenAPI schema objects - #926

Merged
jviotti merged 1 commit into
mainfrom
example-lint
Oct 29, 2026
Merged

jviotti merged 1 commit into
mainfrom
example-lint

Conversation

@jviotti

@jviotti jviotti commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

View guided diff

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@augmentcode

augmentcode Bot commented Oct 29, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Adds linting to catch OpenAPI schema examples that fail validation.
Introduces valid_example for OpenAPI 3.0, 3.1, and 3.2 vocabularies.
Uses exhaustive evaluation for standalone and embedded schemas.
Reports validation messages with instance locations and evaluation paths.
Removes invalid examples with --fix, while skipping OpenAPI 3.0 $ref siblings.
Updates vendored Blaze and CLI rule-list expectations for the additional rule.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

ONLY_CONTINUE_IF(!schema.defines("$ref"));
}

const auto &instance{schema.at("example")};

@augmentcode augmentcode Bot Oct 29, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment on lines +73 to +74
const auto result{evaluator.validate(schema_template.value(), instance,
std::ref(output))};

@augmentcode augmentcode Bot Oct 29, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@jviotti
jviotti merged commit 7300e6e into main Oct 29, 2026
16 checks passed
@jviotti
jviotti deleted the example-lint branch October 29, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant