Repository navigation
fix(core): warn instead of silently dropping unrecognized path-item operations (#24212) - #24969
Conversation
…perations (OpenAPITools#24212) Under --skip-validate-spec, when the parser encounters a path-item member it doesn't recognize (e.g. a future operation like OpenAPI 3.2's 'query' HTTP method), it silently drops it and generation reports success with no indication that an operation is missing. - Detect swagger-parser's "attribute paths.'X'.Y is unexpected" messages and escalate matching ones into an explicit WARN naming exactly which path-item members will be missing from the generated output. - When the parser cannot produce an OpenAPI object at all (e.g. an unsupported spec version), fail immediately with a message that includes the parser's own diagnostics, instead of letting null propagate through several layers before a generic error surfaces later in DefaultGenerator.generate(). Closes OpenAPITools#24212
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
thanks for the PR. please review the feedback from cubic-dev-ai when you've time. cc @OpenAPITools/generator-core-team |
…keys cubic-dev-ai flagged that the greedy path-capture group in UNEXPECTED_PATH_ITEM_ATTRIBUTE could misattribute a nested unexpected attribute as a top-level dropped operation whenever the parser message contains a second quoted segment (e.g. a path whose template itself contains a literal quote, or a typo inside a quoted media-type key). Restrict the path segment to non-quote characters so only the intended single-quoted path name is captured. Also documents the intentional typo in the existing regression fixture so a well-meaning "fix" doesn't silently disable the test it exists for. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Hello, any update on this PR ? |
|
Hi @ray-cha, thanks for checking in! The feedback from cubic-dev-ai has already been addressed. CI is green and there are no merge conflicts — this PR is ready for maintainer review. @wing328 Would you or the core team be able to take another look when you have a moment? Happy to make any further changes if needed. |
|
Apologies — I should have addressed the cubic-dev-ai feedback explicitly in my previous comment. Here is the status of each issue:
Both fixes are already in the current HEAD of this PR. Sorry for the oversight in my earlier reply. |
|
@khayashi4337 thanks for the PR. Will review and let you know if I've any question. |
|
PR merged. Thanks for the enhancement. |
OpenAPITools#24969 was squash-merged into master and conflicts with this branch's own copy of the same change. This branch's versions are kept for all four files because they are a superset of what master received: - CodegenConfigurator / CodegenConfiguratorTest: keep the follow-up review fixes (dots allowed in custom method tokens, thread-scoped log capture) that were made here after OpenAPITools#24969's content was copied in. - issue_24212_unsupported_version.yaml: keep `openapi: 4.0.0`; with the 3.2-capable parser this branch depends on, 3.2.0 is no longer an unsupported version. - pom.xml: keep swagger-parser 2.1.49-SNAPSHOT (master moved 2.1.47 -> 2.1.48); the OpenAPI 3.2 model/parser support is not in any release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Under
--skip-validate-spec, when the OpenAPI parser encounters a path-item member it doesn't recognize (e.g. a future operation like OpenAPI 3.2'squeryHTTP method), it silently drops it. Generation exits 0 with a success message, but the operation is simply absent from the generated output — the only trace is a generic "There were issues with the specification" WARN that doesn't say anything about code being missing.This PR makes that failure mode loud instead of silent:
attribute paths.'X'.Y is unexpectedvalidation messages and, when generation is actually going to proceed, escalates matching ones into an explicit WARN naming exactly which path-item member(s) will be missing from the generated output.OpenAPIobject at all (e.g. because the spec declares a version newer than the parser supports),toContext()now fails immediately with a message that includes the parser's own diagnostics, instead of lettingnullsilently propagate throughContext→ClientOptInput→DefaultGeneratorbefore a generic error surfaces later.Closes #24212.
Why not always hard-fail?
--skip-validate-specexists specifically to let generation continue despite spec issues, so this keeps that contract: generation still succeeds when only unrecognized attributes are present, it just now says so clearly instead of staying silent. When the parser can't produce a document at all, there's nothing to generate from regardless of the flag, so that case fails fast with a clear reason.Testing
CodegenConfiguratorTest(new resource specs undersrc/test/resources/3_0/issue_24212_*.yaml) covering: the warning fires for a genuinely dropped operation, it does not false-positive on an unrelated typo nested inside a path-levelparameters/serversobject, the null-spec case fails with a clear message and no misleading "MISSING" warning, and the pre-existing default (non-skip)SpecValidationExceptionpath is unchanged../bin/generate-samples.sh(all 803 configs) and./bin/utils/export_docs_generators.shper the PR checklist — zero diff, confirming this change doesn't alter any existing generator output.Summary by cubic
Fixes #24212 so
--skip-validate-specno longer silently drops unrecognized path-item operations like OpenAPI 3.2'squery. It now warns with the exact paths and members that will be missing, and fails fast with parser diagnostics when the parser can't produce anOpenAPIobject at all.Bug Fixes
attribute paths.'X'.Y is unexpectedmessages only for single-quoted path names with a simple member token, so neither nested typos nor quoted path templates are misreported as dropped operations.--skip-validate-speccontract: generation still proceeds when only unrecognized attributes are present, and the defaultSpecValidationExceptionpath is unchanged.Written for commit 5abcaf4. Summary will update on new commits.