diff --git a/io.go b/io.go index c5d6044..b4c10a2 100644 --- a/io.go +++ b/io.go @@ -212,14 +212,23 @@ func Save(dir string, cfg *Config, opts ...Option) error { } func findConfigFile(dir string, o *options) ([]byte, string, error) { - path := filepath.Join(dir, "gen.yaml") + absPath, err := filepath.Abs(dir) + if err != nil { + return nil, "", fmt.Errorf("failed to get absolute path: %w", err) + } + + path := filepath.Join(absPath, "gen.yaml") for { data, err := o.readFileFunc(path) if err != nil { if errors.Is(err, fs.ErrNotExist) { currentDir := filepath.Dir(path) - if currentDir == "." || currentDir == "/" { + // Check for the root of the filesystem or path + // ie `.` for `./something` + // or `/` for `/some/absolute/path` in linux + // or `:\\` for `C:\\` in windows + if currentDir == "." || currentDir == "/" || currentDir[1:] == ":\\" { return nil, "", ErrNotFound } diff --git a/io_test.go b/io_test.go index 7ef7ac6..3fe0a29 100644 --- a/io_test.go +++ b/io_test.go @@ -43,6 +43,13 @@ func TestLoad_Success(t *testing.T) { SDKClassName: "SDK", SingleTagPerOp: false, MaintainOpenAPIOrder: true, + UsageSnippets: &UsageSnippets{ + OptionalPropertyRendering: "withExample", + }, + Fixes: &Fixes{ + NameResolutionDec2023: true, + }, + UseClassNamesForArrayFields: true, }, New: map[string]bool{ "go": true, @@ -81,6 +88,12 @@ func TestLoad_Success(t *testing.T) { OmitDescriptionIfSummaryPresent: true, DisableComments: false, }, + UsageSnippets: &UsageSnippets{ + OptionalPropertyRendering: "withExample", + }, + Fixes: &Fixes{ + NameResolutionDec2023: false, + }, }, Features: map[string]map[string]string{}, New: map[string]bool{}, @@ -117,6 +130,12 @@ func TestLoad_Success(t *testing.T) { DisableComments: false, OmitDescriptionIfSummaryPresent: true, }, + UsageSnippets: &UsageSnippets{ + OptionalPropertyRendering: "withExample", + }, + Fixes: &Fixes{ + NameResolutionDec2023: false, + }, }, Features: map[string]map[string]string{ "go": { @@ -157,6 +176,12 @@ func TestLoad_Success(t *testing.T) { DisableComments: false, OmitDescriptionIfSummaryPresent: true, }, + UsageSnippets: &UsageSnippets{ + OptionalPropertyRendering: "withExample", + }, + Fixes: &Fixes{ + NameResolutionDec2023: false, + }, }, Features: map[string]map[string]string{ "go": { @@ -200,6 +225,12 @@ func TestLoad_Success(t *testing.T) { DisableComments: false, OmitDescriptionIfSummaryPresent: true, }, + UsageSnippets: &UsageSnippets{ + OptionalPropertyRendering: "withExample", + }, + Fixes: &Fixes{ + NameResolutionDec2023: false, + }, }, Features: map[string]map[string]string{ "go": {