@@ -118,19 +118,12 @@ func (o OasDiff) mergePaths() error {
118118 if originalPath := basePaths .Value (externalPath ); originalPath == nil {
119119 basePaths .Set (externalPath , removeExternalRefs (externalPathData ))
120120 } else {
121- if o .shouldSkipPathConflict (originalPath , externalPath ) {
122- log .Printf ("Skipping conflict for path: %s" , externalPath )
123- if o .arePathsIdenticalWithExcludeExtensions (externalPath ) {
124- log .Printf ("No doc diff detected for path %s, merging the paths" , externalPath )
125- basePaths .Set (externalPath , removeExternalRefs (externalPathData ))
126- } else {
127- log .Printf ("Doc diff detected failing as allowDocsDiff=true is not supported." )
128- }
121+ err := o .handlePathConflict (originalPath , externalPath )
122+ if err != nil {
123+ return err
129124 }
130125
131- return errors.PathConflictError {
132- Entry : externalPath ,
133- }
126+ basePaths .Set (externalPath , removeExternalRefs (externalPathData ))
134127 }
135128 }
136129 o .base .Spec .Paths = basePaths
@@ -172,6 +165,26 @@ func removeExternalRefs(path *openapi3.PathItem) *openapi3.PathItem {
172165 return path
173166}
174167
168+ // handlePathConflict handles the path conflict by checking if the conflict should be skipped or not.
169+ func (o OasDiff ) handlePathConflict (basePath * openapi3.PathItem , basePathName string ) error {
170+ if ! o .shouldSkipPathConflict (basePath , basePathName ) {
171+ return errors.PathConflictError {
172+ Entry : basePathName ,
173+ }
174+ }
175+
176+ log .Printf ("Skipping conflict for path: %s" , basePathName )
177+ if o .arePathsIdenticalWithExcludeExtensions (basePathName ) {
178+ log .Printf ("No doc diff detected for path %s, merging the paths" , basePathName )
179+ return nil
180+ }
181+
182+ log .Printf ("Doc diff detected failing as allowDocsDiff=true is not supported." )
183+ return errors.PathConflictError {
184+ Entry : basePathName ,
185+ }
186+ }
187+
175188// shouldSkipConflict checks if the conflict should be skipped.
176189// The method goes through each path operation and performs the following checks:
177190// 1. Validates if both paths have same operations, if not, then it returns false.
0 commit comments