diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1547b99..cf60623 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.81" + ".": "0.1.0-alpha.82" } diff --git a/.stats.yml b/.stats.yml index d6227e8..0b3b470 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 22 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-ef33241ec003fafbf4f2ffe434c3d8c2ac0ba929137942185663ff59974d2138.yml openapi_spec_hash: 87bd0d9c684517522cbbbd48bbe8ad83 -config_hash: 038aa9961f259a8ee53e61dfb2454763 +config_hash: 63178ec4b1d2ea5636c8619cffcf129b diff --git a/CHANGELOG.md b/CHANGELOG.md index e238eb1..38bceb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.1.0-alpha.82 (2026-03-12) + +Full Changelog: [v0.1.0-alpha.81...v0.1.0-alpha.82](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.81...v0.1.0-alpha.82) + +### Bug Fixes + +* fix api-key being passed into command ([74a2a46](https://github.com/stainless-api/stainless-api-cli/commit/74a2a46a697ca526395d7ee360c54204d5f86656)) +* fix auth ([ace94ad](https://github.com/stainless-api/stainless-api-cli/commit/ace94ad5a0ee88b334b5752e12cfa8c60e9a88ca)) +* fix for test cases with newlines in YAML and better error reporting ([d7ddfce](https://github.com/stainless-api/stainless-api-cli/commit/d7ddfcefaf919400d052b9741eb4f61163c6da62)) + ## 0.1.0-alpha.81 (2026-03-11) Full Changelog: [v0.1.0-alpha.80...v0.1.0-alpha.81](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.80...v0.1.0-alpha.81) diff --git a/internal/requestflag/requestflag.go b/internal/requestflag/requestflag.go index 986afed..7698744 100644 --- a/internal/requestflag/requestflag.go +++ b/internal/requestflag/requestflag.go @@ -28,6 +28,7 @@ type Flag[ Sources cli.ValueSourceChain // sources to load flag value from Required bool // whether the flag is required or not Hidden bool // whether to hide the flag in help output + Local bool // whether or not this flag should be applied to subcommands Default T // default value for this flag if not set by from any source Aliases []string // aliases that are allowed for this flag Validator func(T) error // custom function to validate this flag value @@ -55,6 +56,10 @@ type InRequest interface { IsBodyRoot() bool } +func (f Flag[T]) IsLocal() bool { + return f.Local +} + func (f Flag[T]) GetQueryPath() string { return f.QueryPath } diff --git a/pkg/cmd/cmdutil.go b/pkg/cmd/cmdutil.go index d23fce0..f271454 100644 --- a/pkg/cmd/cmdutil.go +++ b/pkg/cmd/cmdutil.go @@ -39,8 +39,14 @@ func getDefaultRequestOptions(cmd *cli.Command) []option.RequestOption { option.WithHeader("X-Stainless-Package-Version", Version), option.WithHeader("X-Stainless-Runtime", "cli"), option.WithHeader("X-Stainless-CLI-Command", cmd.FullName()), - option.WithAPIKey(cmd.String("api-key")), - option.WithProject(cmd.String("project")), + } + + if cmd.IsSet("api-key") { + opts = append(opts, option.WithAPIKey(cmd.String("api-key"))) + } + + if cmd.IsSet("project") { + opts = append(opts, option.WithProject(cmd.String("project"))) } // Override base URL if the --base-url flag is provided diff --git a/pkg/cmd/flagoptions.go b/pkg/cmd/flagoptions.go index 533ebab..9aee10d 100644 --- a/pkg/cmd/flagoptions.go +++ b/pkg/cmd/flagoptions.go @@ -227,19 +227,20 @@ func flagOptions( if len(pipeData) > 0 { var bodyData any - if err := yaml.Unmarshal(pipeData, &bodyData); err == nil { - if bodyMap, ok := bodyData.(map[string]any); ok { - if flagMap, ok := requestContents.Body.(map[string]any); ok { - maps.Copy(bodyMap, flagMap) - requestContents.Body = bodyMap - } else { - bodyData = requestContents.Body - } - } else if flagMap, ok := requestContents.Body.(map[string]any); ok && len(flagMap) > 0 { - return nil, fmt.Errorf("Cannot merge flags with a body that is not a map: %v", bodyData) + if err := yaml.Unmarshal(pipeData, &bodyData); err != nil { + return nil, fmt.Errorf("Failed to parse piped data as YAML/JSON:\n%w", err) + } + if bodyMap, ok := bodyData.(map[string]any); ok { + if flagMap, ok := requestContents.Body.(map[string]any); ok { + maps.Copy(bodyMap, flagMap) + requestContents.Body = bodyMap } else { - requestContents.Body = bodyData + bodyData = requestContents.Body } + } else if flagMap, ok := requestContents.Body.(map[string]any); ok && len(flagMap) > 0 { + return nil, fmt.Errorf("Cannot merge flags with a body that is not a map: %v", bodyData) + } else { + requestContents.Body = bodyData } } } diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index caefff0..23013c3 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -2,4 +2,4 @@ package cmd -const Version = "0.1.0-alpha.81" // x-release-please-version +const Version = "0.1.0-alpha.82" // x-release-please-version