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 — Drop paths left empty by tag and operationId filtering by 56steve · Pull Request #2638 · oapi-codegen/oapi-codegen

Conversation

@56steve

@56steve 56steve commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

When include-tags, exclude-tags, include-operation-ids or exclude-operation-ids removed every operation of a path, the path item stayed in the spec as an empty entry, so the embedded spec still listed it (for example "/t2":{}). I now delete a path once filtering has removed all of its operations. Paths that never had operations are left alone. Two existing prune tests asserted the old behaviour and now check that the path is gone, and I added a test covering both filter kinds.

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
@56steve
Drop paths with no operations left after tag and operationId filtering
0dc0340
@56steve
56steve requested a review from a team as a code owner October 29, 2026 04:48
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches code generation runs that use operation filters.

Preserve compatibility for previously generated types before merging.

Findings

  1. P1 Previously generated types disappear ▶
  2. P2 Path preservation lacks tests ▶
Fix with agent prompt
### Issue 1
pkg/codegen/filter.go:40-41
Deleting the whole path also removes references from its shared parameters. If a filtered-out path has a parameter referencing `#/components/schemas/ItemID`, that reference previously kept `ItemID` in the generated Go code. Now `pruneUnusedComponents` deletes it when nothing else references it, breaking downstream code that uses the exported type. Both filter helpers have this problem.

The repository requires compatibility protection for changes to generated APIs. Preserve the existing type output by default or make this broader change opt-in.

### Issue 2
pkg/codegen/filter_test.go:161-170
The new test checks only paths with one operation each. Add a path that starts empty and a path with both a kept and a removed operation, then assert that both paths survive under each filter kind. These cases protect the two deletion guards; the current tests would still pass if either guard were removed.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR removes paths after tag or operation-ID filtering removes their last operation.

  • Filtered paths disappear once none of their operations remain.

Reviews (1) · Last reviewed commit: "Drop paths with no operations left after..." · Reviewed by Greptile

All reactions

Sorry, something went wrong.

Uh oh!

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

greptile-apps[bot]
greptile-apps Bot reviewed Oct 29, 2026
View reviewed changes
Comment thread pkg/codegen/filter.go
Comment on lines +40 to +41
if len(names) > 0 && len(pathItem.Operations()) == 0 {
paths.Delete(path)

@greptile-apps greptile-apps Bot Oct 29, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

P1 Previously generated types disappear

Deleting the whole path also removes references from its shared parameters. If a filtered-out path has a parameter referencing #/components/schemas/ItemID, that reference previously kept ItemID in the generated Go code. Now pruneUnusedComponents deletes it when nothing else references it, breaking downstream code that uses the exported type. Both filter helpers have this problem.

The repository requires compatibility protection for changes to generated APIs. Preserve the existing type output by default or make this broader change opt-in.

Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/codegen/filter.go
Line: 40-41

Comment:
**Previously generated types disappear**

Deleting the whole path also removes references from its shared parameters. If a filtered-out path has a parameter referencing `#/components/schemas/ItemID`, that reference previously kept `ItemID` in the generated Go code. Now `pruneUnusedComponents` deletes it when nothing else references it, breaking downstream code that uses the exported type. Both filter helpers have this problem.

The repository requires compatibility protection for changes to generated APIs. Preserve the existing type output by default or make this broader change opt-in.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pkg/codegen/filter_test.go
Comment on lines +161 to +170
t.Run("by tag", func(t *testing.T) {
swagger := load(t)
filterOperationsByTag(swagger, Configuration{OutputOptions: OutputOptions{IncludeTags: []string{"kept"}}})
assert.Equal(t, []string{"/kept"}, swagger.Paths.Keys())
})

t.Run("by operation id", func(t *testing.T) {
swagger := load(t)
filterOperationsByOperationID(swagger, Configuration{OutputOptions: OutputOptions{ExcludeOperationIDs: []string{"getDropped"}}})
assert.Equal(t, []string{"/kept"}, swagger.Paths.Keys())

@greptile-apps greptile-apps Bot Oct 29, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

P2 Path preservation lacks tests

The new test checks only paths with one operation each. Add a path that starts empty and a path with both a kept and a removed operation, then assert that both paths survive under each filter kind. These cases protect the two deletion guards; the current tests would still pass if either guard were removed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/codegen/filter_test.go
Line: 161-170

Comment:
**Path preservation lacks tests**

The new test checks only paths with one operation each. Add a path that starts empty and a path with both a kept and a removed operation, then assert that both paths survive under each filter kind. These cases protect the two deletion guards; the current tests would still pass if either guard were removed.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sorry, something went wrong.

Uh oh!

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

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments

At least 1 approving review is required to merge this pull request.

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

@56steve
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.