@@ -63,7 +63,7 @@ func filterOperations(model *v3high.Document, cfg FilterConfig) bool {
6363 continue
6464 }
6565
66- removed = filterPathItemOperations (pathItem , cfg , removed )
66+ removed = filterPathItemOperations (path , pathItem , cfg , removed )
6767 }
6868
6969 // Filter webhooks
@@ -86,16 +86,20 @@ func filterOperations(model *v3high.Document, cfg FilterConfig) bool {
8686 continue
8787 }
8888
89- removed = filterPathItemOperations (pathItem , cfg , removed )
89+ // Mirror codegen.go's webhook operation ID synthesis so the
90+ // filter sees the same canonical IDs the rest of the pipeline
91+ // emits for webhook operations.
92+ removed = filterPathItemOperations ("/webhooks/" + name , pathItem , cfg , removed )
9093 }
9194 }
9295
9396 return removed
9497}
9598
9699// filterPathItemOperations filters operations within a PathItem by tags and operation IDs.
97- // Returns the updated removed flag.
98- func filterPathItemOperations (pathItem * v3high.PathItem , cfg FilterConfig , removed bool ) bool {
100+ // The path is needed to canonicalize operation IDs via CreateOperationID so
101+ // filters work for specs that omit `operationId`. Returns the updated removed flag.
102+ func filterPathItemOperations (path string , pathItem * v3high.PathItem , cfg FilterConfig , removed bool ) bool {
99103 for method , op := range pathItem .GetOperations ().FromOldest () {
100104 remove := false
101105
@@ -121,12 +125,23 @@ func filterPathItemOperations(pathItem *v3high.PathItem, cfg FilterConfig, remov
121125 }
122126 }
123127
124- // OperationIDs
125- if len (cfg .Exclude .OperationIDs ) > 0 && slices .Contains (cfg .Exclude .OperationIDs , op .OperationId ) {
126- remove = true
127- }
128- if len (cfg .Include .OperationIDs ) > 0 && ! slices .Contains (cfg .Include .OperationIDs , op .OperationId ) {
129- remove = true
128+ // OperationIDs: compare against the literal operationId when the
129+ // spec declares one (preserves existing behavior). For specs that
130+ // omit `operationId`, fall back to the synthesized ID so the
131+ // filter matches what downstream code uses (see codegen.go's
132+ // CreateOperationID calls). Without this fallback, filters
133+ // against operationId-less specs would silently match nothing.
134+ if len (cfg .Exclude .OperationIDs ) > 0 || len (cfg .Include .OperationIDs ) > 0 {
135+ opID := op .OperationId
136+ if opID == "" {
137+ opID , _ = CreateOperationID (method , path , "" )
138+ }
139+ if len (cfg .Exclude .OperationIDs ) > 0 && slices .Contains (cfg .Exclude .OperationIDs , opID ) {
140+ remove = true
141+ }
142+ if len (cfg .Include .OperationIDs ) > 0 && ! slices .Contains (cfg .Include .OperationIDs , opID ) {
143+ remove = true
144+ }
130145 }
131146
132147 if remove {
0 commit comments