Skip to content

Commit 6ae9059

Browse files
stainless-app[bot]yjp20
authored andcommitted
feat: Expose connection-specific decorated OAS
1 parent d24278d commit 6ae9059

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 19
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-5c1008fd27f64bcde1a146a4158f1c3113b4e13437a4d880bd6811fb063cfcd6.yml
3-
openapi_spec_hash: 9583f62164b5dc15b10051dad6a7fca4
4-
config_hash: e895f7992a607a15865ed026cbe5470d
1+
configured_endpoints: 20
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-030e47a1bfd79a657974f5beddd685940ec04b1aa1786c3b2cb0f4610ad2b42c.yml
3+
openapi_spec_hash: 33b337af28bcc1c9aa1a5218acf2a7fe
4+
config_hash: ebaca4741c1a2caf1372aa5bba88d4c7

pkg/cmd/cmd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ stl builds create --branch <branch>`,
164164

165165
&lintCommand,
166166

167+
{
168+
Name: "spec",
169+
Category: "API RESOURCE",
170+
Commands: []*cli.Command{
171+
&specRetrieveDecoratedSpec,
172+
},
173+
},
167174
{
168175
Name: "@manpages",
169176
Usage: "Generate documentation for 'man'",

pkg/cmd/spec.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package cmd
4+
5+
import (
6+
"context"
7+
"fmt"
8+
9+
"github.com/stainless-api/stainless-api-go"
10+
"github.com/stainless-api/stainless-api-go/option"
11+
"github.com/tidwall/gjson"
12+
"github.com/urfave/cli/v3"
13+
)
14+
15+
var specRetrieveDecoratedSpec = cli.Command{
16+
Name: "retrieve-decorated-spec",
17+
Usage: "Retrieve the decorated spec for a given application and project.",
18+
Flags: []cli.Flag{
19+
&cli.StringFlag{
20+
Name: "client-id",
21+
},
22+
&cli.StringFlag{
23+
Name: "project-name",
24+
},
25+
},
26+
Action: handleSpecRetrieveDecoratedSpec,
27+
HideHelpCommand: true,
28+
}
29+
30+
func handleSpecRetrieveDecoratedSpec(ctx context.Context, cmd *cli.Command) error {
31+
cc := getAPICommandContext(cmd)
32+
unusedArgs := cmd.Args().Slice()
33+
if !cmd.IsSet("project-name") && len(unusedArgs) > 0 {
34+
cmd.Set("project-name", unusedArgs[0])
35+
unusedArgs = unusedArgs[1:]
36+
}
37+
if len(unusedArgs) > 0 {
38+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
39+
}
40+
params := stainless.SpecGetDecoratedSpecParams{}
41+
if cmd.IsSet("client-id") {
42+
params.ClientID = cmd.Value("client-id").(string)
43+
}
44+
var res []byte
45+
_, err := cc.client.Spec.GetDecoratedSpec(
46+
context.TODO(),
47+
cmd.Value("project-name").(string),
48+
params,
49+
option.WithMiddleware(cc.AsMiddleware()),
50+
option.WithResponseBodyInto(&res),
51+
)
52+
if err != nil {
53+
return err
54+
}
55+
56+
json := gjson.Parse(string(res))
57+
format := cmd.Root().String("format")
58+
transform := cmd.Root().String("transform")
59+
return ShowJSON("spec retrieve-decorated-spec", json, format, transform)
60+
}

0 commit comments

Comments
 (0)