GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(codegen): traverse references in all supported OpenAPI fields by abramchikd · Pull Request #2554 · oapi-codegen/oapi-codegen

Conversation

@abramchikd

@abramchikd abramchikd commented Sep 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

fix(codegen): traverse references in all supported OpenAPI fields

Summary

Extend the codegen reference walker so component pruning discovers references
from all SchemaRef-bearing fields supported by the current kin-openapi model,
as well as from webhooks and nested media-type content.

Previously, a component referenced only from an OpenAPI 3.1 JSON Schema keyword,
an OpenAPI 3.2 itemSchema, a webhook, header content, or an encoding header
could be treated as unused and removed from components.

Problem

pruneUnusedComponents determines which components are reachable through
findComponentRefs, which in turn uses the shared walkSwagger traversal.
That traversal covered the original OpenAPI 3.0 schema locations but did not
keep pace with fields added to kin-openapi for OpenAPI 3.1 and 3.2.

For example, the reference in this OpenAPI 3.1 schema was not visited:

components:
  schemas:
    Text:
      type: string
    Container:
      type: object
      propertyNames:
        $ref: '#/components/schemas/Text'

The same problem affected references under prefixItems, contains,
patternProperties, dependentSchemas, unevaluatedItems,
unevaluatedProperties, if/then/else, $defs, and contentSchema.

Root-level webhooks were also skipped. In addition, media-type traversal did not
visit OpenAPI 3.2 itemSchema, schemas inside Header.Content, or headers nested
under MediaType.Encoding.

Changes

  • Visit root-level webhooks using the same path-item traversal as normal paths.
  • Continue walking components when an OpenAPI 3.1 document omits paths.
  • Centralize traversal of child schema references in schemaChildRefs.
  • Cover every SchemaRef-bearing field currently exposed by
    openapi3.Schema, including the OpenAPI 3.1 JSON Schema keywords.
  • Centralize media-type traversal in walkContent.
  • Visit both schema and OpenAPI 3.2 itemSchema in media types.
  • Visit schemas and examples nested in parameter, request-body, response, and
    header content.
  • Visit headers nested under media-type encodings.
  • Reuse path-item traversal for callbacks.

This pull request was created with the assistance of OpenAI Codex.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@abramchikd
fix/complete-openapi-ref-traversal
6ca7e5f
@abramchikd
abramchikd requested a review from a team as a code owner September 15, 2026 08:52
@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High impact] The PR appears safe to merge; no actionable issue remains in the changes since the previous review.

Summary

Extends component-reference traversal so pruning preserves schemas referenced through OpenAPI 3.1/3.2 fields, webhooks, nested content, and encoding headers.

  • Centralizes schema-child and media-type traversal.
  • Adds cycle protection for resolved recursive schema references.
  • Adds focused regression coverage for the newly traversed locations.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into fix/complete-op..." · Reviewed by Greptile

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abramchikd
Merge branch 'main' into fix/complete-openapi-ref-traversal
36322f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@abramchikd
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.