feat: no silent drops - #132
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new $ref-sibling warning is skipped for PathItem contexts, which can leave ignored PathItem sibling keys without the intended “no silent drops” diagnostic.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens generator diagnostics to avoid silently dropping spec/config content by adding pre-deserialization key/shape inspection, plus targeted runtime warnings for currently-ignored but valid OpenAPI features and translation limits.
Changes:
- Add an OpenAPI key/shape inspection pass (
coverage) invoked by the loader for root and referenced documents, producing aggregatedInvalidSpecerrors and warnings. - Add YAML config unknown-key diagnostics by comparing the input YAML tree against
Config::default()’s serialized shape, emitting warnings while keeping parse errors unchanged. - Expand lowering-time warnings for unsupported/ignored operation details (media-type selection, scalar parameter enum ignored, non-default parameter styles) and document the new behavior.
File summaries
| File | Description |
|---|---|
| README.md | Updates the high-level behavior note to reflect “warn then ignore” for unknown config keys. |
| docs/design.md | Documents the new inspection/diagnostics model (errors vs warnings, pointers, referenced docs). |
| docs/configuration.md | Clarifies config compatibility: unknown keys warn (including nested sections) while invalid known values still error. |
| crates/oapi-codegen/tests/diagnostics_operations.rs | Adds integration tests asserting warnings don’t change generated output for various operation-level cases. |
| crates/oapi-codegen/tests/check_mode.rs | Adds tests for config unknown-key warnings, spec unknown-key failures, referenced-doc diagnostics, and JSON entry points. |
| crates/oapi-codegen/src/lower/schema.rs | Emits a warning when an Any schema is non-empty but must fall back to serde_json::Value. |
| crates/oapi-codegen/src/lower/paths.rs | Adds warnings for unsupported parameter styles, ignored scalar enums, and discarded/unsupported media types (including referenced origins). |
| crates/oapi-codegen/src/loader.rs | Invokes the new coverage::check on root and referenced documents before typed deserialization. |
| crates/oapi-codegen/src/lib.rs | Wires new internal modules (coverage, diagnostic) into the crate. |
| crates/oapi-codegen/src/error.rs | Introduces Error::InvalidSpec for unknown keys/invalid shapes and integrates it into Display/source. |
| crates/oapi-codegen/src/diagnostic.rs | Adds shared warning formatting and JSON-pointer escaping utility. |
| crates/oapi-codegen/src/coverage.rs | Implements the OpenAPI key catalogue, traversal, warning emission, and aggregated invalid-spec reporting. |
| crates/oapi-codegen/src/console.rs | Adds a CLI hint for InvalidSpec errors. |
| crates/oapi-codegen/src/config.rs | Adds config unknown-key warnings via untyped YAML inspection against the default serialized shape. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
🎉 This PR is included in version 1.3.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #97