@@ -118,7 +118,7 @@ func (o OasDiff) mergePaths() error {
118118 if originalPath := basePaths .Value (externalPath ); originalPath == nil {
119119 basePaths .Set (externalPath , removeExternalRefs (externalPathData ))
120120 } else {
121- if shouldSkipPathConflict (originalPath , externalPathData , externalPath ) {
121+ if o . shouldSkipPathConflict (originalPath , externalPath ) {
122122 log .Printf ("Skipping conflict for path: %s" , externalPath )
123123 if o .arePathsIdenticalWithExcludeExtensions (externalPath ) {
124124 log .Printf ("No doc diff detected for path %s, merging the paths" , externalPath )
@@ -172,6 +172,25 @@ func removeExternalRefs(path *openapi3.PathItem) *openapi3.PathItem {
172172 return path
173173}
174174
175+ // shouldSkipConflict checks if the conflict should be skipped.
176+ // The method goes through each path operation and performs the following checks:
177+ // 1. Validates if both paths have same operations, if not, then it returns false.
178+ // 2. If both paths have the same operations, then it checks if there is an x-xgen-soa-migration annotation.
179+ // If there is no annotation, then it returns false.
180+ func (o OasDiff ) shouldSkipPathConflict (basePath * openapi3.PathItem , basePathName string ) bool {
181+ if ok := o .specDiff .PathsDiff .Modified [basePathName ].OperationsDiff .Added ; ! ok .Empty () {
182+ return false
183+ }
184+
185+ if ok := o .specDiff .PathsDiff .Modified [basePathName ].OperationsDiff .Deleted ; ! ok .Empty () {
186+ return false
187+ }
188+
189+ // now check if there is an x-xgen-soa-migration annotation in any of the operations, but if any of the operations
190+ // doesn't have, then we should not skip the conflict
191+ return allOperationsHaveExtension (basePath , basePathName , xgenSoaMigration )
192+ }
193+
175194// updateExternalRefResponses updates the external references of OASes to remove the reference to openapi-mms.json
176195// in the Responses.
177196// A Response can have an external ref in Response.Ref or in its content (Response.Content.Schema.Ref)
0 commit comments