diff --git a/tools/cli/internal/openapi/errors/merge_conflict_error.go b/tools/cli/internal/openapi/errors/merge_conflict_error.go index 3953142d80..cef6923a03 100644 --- a/tools/cli/internal/openapi/errors/merge_conflict_error.go +++ b/tools/cli/internal/openapi/errors/merge_conflict_error.go @@ -46,20 +46,27 @@ func (e ResponseConflictError) Error() string { } type SchemaConflictError struct { - Entry string + Entry string + BaseSpecLocation string + ExternalSpecLocation string } func (e SchemaConflictError) Error() string { - return fmt.Sprintf("there was a conflict on a Schema component: %q", e.Entry) + return fmt.Sprintf("there was a conflict on a Schema component: %q. Base Spec: %q, External Spec: %q", + e.Entry, e.BaseSpecLocation, e.ExternalSpecLocation) } type TagConflictError struct { - Entry string - Description string + Entry string + Description string + BaseSpecLocation string + ExternalSpecLocation string } func (e TagConflictError) Error() string { - return fmt.Sprintf("there was a conflict with the Tag %q with the description: %q", e.Entry, e.Description) + return fmt.Sprintf( + "there was a conflict with the Tag %q with the description: %q. Base Spec: %q, External Spec: %q", + e.Entry, e.Description, e.BaseSpecLocation, e.ExternalSpecLocation) } type PathDocsDiffConflictError struct { diff --git a/tools/cli/internal/openapi/oasdiff.go b/tools/cli/internal/openapi/oasdiff.go index e63ef5b1f1..d330af6823 100644 --- a/tools/cli/internal/openapi/oasdiff.go +++ b/tools/cli/internal/openapi/oasdiff.go @@ -297,8 +297,10 @@ func (o OasDiff) mergeTags() error { baseTags = append(baseTags, v) } else { return errors.TagConflictError{ - Entry: v.Name, - Description: v.Description, + Entry: v.Name, + Description: v.Description, + BaseSpecLocation: o.base.Url, + ExternalSpecLocation: o.external.Url, } } } @@ -419,7 +421,9 @@ func (o OasDiff) mergeSchemas() error { // The schemas have the same name but different definitions return errors.SchemaConflictError{ - Entry: k, + Entry: k, + BaseSpecLocation: o.base.Url, + ExternalSpecLocation: o.external.Url, } } } diff --git a/tools/cli/internal/openapi/openapi3.go b/tools/cli/internal/openapi/openapi3.go index 559933ea27..15da0e635c 100644 --- a/tools/cli/internal/openapi/openapi3.go +++ b/tools/cli/internal/openapi/openapi3.go @@ -48,6 +48,7 @@ func (o *OpenAPI3) WithExcludedPrivatePaths() *OpenAPI3 { func (o *OpenAPI3) CreateOpenAPISpecFromPath(path string) (*load.SpecInfo, error) { o.Loader.IsExternalRefsAllowed = o.IsExternalRefsAllowed spec, err := load.NewSpecInfo(o.Loader, load.NewSource(path)) + spec.Url = path if err != nil { return nil, err } diff --git a/tools/cli/test/e2e/cli/merge_test.go b/tools/cli/test/e2e/cli/merge_test.go index 66bb9a3d47..b64ca02d30 100644 --- a/tools/cli/test/e2e/cli/merge_test.go +++ b/tools/cli/test/e2e/cli/merge_test.go @@ -2,6 +2,7 @@ package cli import ( "bytes" + "fmt" "os" "os/exec" "testing" @@ -100,7 +101,9 @@ func TestMerge(t *testing.T) { resp, err := cmd.CombinedOutput() stringResponse := string(resp) require.Error(t, err, stringResponse) - assert.Contains(t, stringResponse, "Error: there was a conflict with the Tag \"Events\" with the description: \"Returns information about the MongoDB Atlas Specification.\"") //nolint:lll // Line is over 120 characters + assert.Contains(t, stringResponse, fmt.Sprintf("Error: there was a conflict with the Tag \"Events\""+ + " with the description: \"Returns information about the MongoDB Atlas Specification.\"."+ + " Base Spec: %q, External Spec: %q", base, authnSpec)) }) t.Run("Expecting Error: not identical component", func(t *testing.T) { @@ -122,6 +125,9 @@ func TestMerge(t *testing.T) { resp, err := cmd.CombinedOutput() stringResponse := string(resp) require.Error(t, err, stringResponse) - assert.Contains(t, stringResponse, "Error: there was a conflict on a Schema component: \"ApiError\"") + assert.Contains(t, stringResponse, + fmt.Sprintf( + "Error: there was a conflict on a Schema component: \"ApiError\". Base Spec: %q, "+ + "External Spec: %q", base, apiRegistrySpec)) }) }