@@ -761,12 +761,6 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
761761 op , path2 := g .buildOperationV3 (
762762 d , operationID , service .GoName , comment , defaultHost , path , body , inputMessage , outputMessage )
763763
764- // Merge any `Operation` annotations with the current
765- extOperation := proto .GetExtension (method .Desc .Options (), v3 .E_Operation )
766- if extOperation != nil {
767- proto .Merge (op , extOperation .(* v3.Operation ))
768- }
769-
770764 // Merge any `Service` annotations with the current
771765 if extService != nil {
772766 op .Parameters = append (op .Parameters , extService .Parameters ... )
@@ -778,6 +772,12 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
778772 proto .Merge (op .ExternalDocs , extService .ExternalDocs )
779773 }
780774 }
775+
776+ // Merge any `Operation` annotations with the current
777+ extOperation := proto .GetExtension (method .Desc .Options (), v3 .E_Operation )
778+ if extOperation != nil {
779+ proto .Merge (op , extOperation .(* v3.Operation ))
780+ }
781781
782782 for _ , v := range op .Parameters {
783783 if v .Oneof == nil {
@@ -811,6 +811,16 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
811811 tags = append (tags , v )
812812 }
813813
814+ var extMap = make (map [string ]* v3.NamedAny )
815+ for _ , v := range op .SpecificationExtension {
816+ extMap [v .Name ] = v
817+ }
818+
819+ op .SpecificationExtension = op .SpecificationExtension [:0 ]
820+ for _ , v := range extMap {
821+ op .SpecificationExtension = append (op .SpecificationExtension , v )
822+ }
823+
814824 op .Tags = tags
815825 g .addOperationToDocumentV3 (d , op , path2 , methodName )
816826 }
0 commit comments