Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions tools/cli/internal/openapi/errors/merge_conflict_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions tools/cli/internal/openapi/oasdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tools/cli/internal/openapi/openapi3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions tools/cli/test/e2e/cli/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"bytes"
"fmt"
"os"
"os/exec"
"testing"
Expand Down Expand Up @@ -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) {
Expand All @@ -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))
})
}
Loading