Skip to content

fix(core): warn instead of silently dropping unrecognized path-item operations (#24212) - #24969

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
khayashi4337:fix/24212-warn-on-dropped-unrecognized-path-item-operations
Oct 21, 2026
Merged

wing328 merged 2 commits into
OpenAPITools:masterfrom
khayashi4337:fix/24212-warn-on-dropped-unrecognized-path-item-operations

Conversation

@khayashi4337

@khayashi4337 khayashi4337 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

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's query HTTP 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:

  • Detects swagger-parser's attribute paths.'X'.Y is unexpected validation 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.
  • When the parser cannot produce an OpenAPI object 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 letting null silently propagate through Context → ClientOptInput → DefaultGenerator before a generic error surfaces later.

Closes #24212.

Why not always hard-fail?

--skip-validate-spec exists 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

  • Added 4 unit tests to CodegenConfiguratorTest (new resource specs under src/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-level parameters/servers object, the null-spec case fails with a clear message and no misleading "MISSING" warning, and the pre-existing default (non-skip) SpecValidationException path is unchanged.
  • Manually verified against the issue's own repro spec and several hand-crafted edge cases (nested parameter typo, path-level server typo, OpenAPI 3.2 version).
  • Ran ./bin/generate-samples.sh (all 803 configs) and ./bin/utils/export_docs_generators.sh per the PR checklist — zero diff, confirming this change doesn't alter any existing generator output.

Summary by cubic

Fixes #24212 so --skip-validate-spec no longer silently drops unrecognized path-item operations like OpenAPI 3.2's query. 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 an OpenAPI object at all.

Bug Fixes

  • Detects swagger-parser's attribute paths.'X'.Y is unexpected messages only for single-quoted path names with a simple member token, so neither nested typos nor quoted path templates are misreported as dropped operations.
  • Keeps the --skip-validate-spec contract: generation still proceeds when only unrecognized attributes are present, and the default SpecValidationException path is unchanged.
  • Adds regression tests for the warning, both false-positive shapes, null-spec failure, and default validation.

Written for commit 5abcaf4. Summary will update on new commits.

Review in cubic

…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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@wing328

wing328 commented Sep 21, 2026

Copy link
Copy Markdown
Member

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>
@ray-cha

ray-cha commented Oct 20, 2026

Copy link
Copy Markdown

Hello, any update on this PR ?

@khayashi4337

Copy link
Copy Markdown
Contributor Author

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.

@khayashi4337

Copy link
Copy Markdown
Contributor Author

Apologies — I should have addressed the cubic-dev-ai feedback explicitly in my previous comment. Here is the status of each issue:

  • P2 (greedy regex in UNEXPECTED_PATH_ITEM_ATTRIBUTE): Fixed. Changed the path capture group from (.+) to ([^']+) so nested unexpected attributes (e.g. a typo inside a parameter object) are no longer misclassified as dropped path-item operations.

  • P3 (intentional typo in test fixture lacks explanation): Fixed. Added a comment block at the top of issue_24212_path_item_parameter_typo.yaml explaining that the requried typo is intentional and what it exercises.

Both fixes are already in the current HEAD of this PR. Sorry for the oversight in my earlier reply.

@wing328

wing328 commented Oct 20, 2026

Copy link
Copy Markdown
Member

@khayashi4337 thanks for the PR. Will review and let you know if I've any question.

@wing328
wing328 merged commit 83a4a0c into OpenAPITools:master Oct 21, 2026
15 checks passed
@wing328

wing328 commented Oct 21, 2026

Copy link
Copy Markdown
Member

PR merged. Thanks for the enhancement.

@wing328 wing328 added this to the 7.27.0 milestone Oct 21, 2026
khayashi4337 added a commit to khayashi4337/openapi-generator that referenced this pull request Oct 22, 2026
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>
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.

[BUG] Unrecognized path-item operations (e.g. OpenAPI 3.2 'query') are silently dropped from generated code with --skip-validate-spec

3 participants