diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 92f27eb..02bee40 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,22 +1,21 @@ lockVersion: 2.0.0 id: 2858c6d9-f946-4185-ae68-3b8e708830fb management: - docChecksum: af467caf61bea274c32dd872e84f602e + docChecksum: a857476fabbb29418727d7b46e390a02 docVersion: 0.4.0 - speakeasyVersion: 1.477.0 - generationVersion: 2.497.0 - releaseVersion: 3.21.0 - configChecksum: 12e793493549628200c7c1d578f87af9 + speakeasyVersion: 1.481.1 + generationVersion: 2.500.5 + releaseVersion: 3.22.0 + configChecksum: f7c2163f50e57902cb5767a7534de7f9 repoURL: https://github.com/speakeasy-api/speakeasy-client-sdk-go.git repoSubDirectory: . installationURL: https://github.com/speakeasy-api/speakeasy-client-sdk-go published: true features: go: - acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 constsAndDefaults: 0.1.6 - core: 3.6.9 + core: 3.6.12 deepObjectParams: 0.1.1 defaultEnabledRetries: 0.2.0 deprecations: 2.81.2 @@ -809,10 +808,16 @@ examples: application/json: {"message": "", "status_code": 140843} 5XX: application/json: {"message": "", "status_code": 632138} + default: + requestBody: + multipart/form-data: {"language": "", "schema_file": {"": "example.file"}} + responses: + 2XX: + application/json: {"snippets": [{"code": "import { Petstore } from \"petstore-sdk\";\n\nconst petstore = new Petstore({\n apiKey: \"\",\n});\n\nasync function run() {\n const result = await petstore.pet.getById({\n id: 137396,\n });\n\n // Handle the result\n console.log(result);\n}\n\nrun();", "language": "typescript", "method": "get", "operationId": "getPetById", "path": "/pet/{id}"}]} generateCodeSamplePreviewAsync: speakeasy-default-generate-code-sample-preview-async: requestBody: - multipart/form-data: {"languages": ["", "", ""], "schema_file": {"": "example.file"}} + multipart/form-data: {"language": "", "schema_file": {"": "example.file"}} responses: "202": application/json: {"job_id": "", "status": "running"} @@ -858,6 +863,13 @@ examples: application/json: {"message": "", "status_code": 44984} 5XX: application/json: {"message": "", "status_code": 416783} + default: + parameters: + path: + jobID: "" + responses: + 2XX: + application/json: {"snippets": [{"code": "import { Petstore } from \"petstore-sdk\";\n\nconst petstore = new Petstore({\n apiKey: \"\",\n});\n\nasync function run() {\n const result = await petstore.pet.getById({\n id: 137396,\n });\n\n // Handle the result\n console.log(result);\n}\n\nrun();", "language": "typescript", "method": "get", "operationId": "getPetById", "path": "/pet/{id}"}]} checkGithubAccess: speakeasy-default-check-github-access: parameters: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index f77c93a..1fde107 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.477.0 +speakeasyVersion: 1.481.1 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:09ff689e93c381070f346714a7fb3083f1a6bd568ef630b21db0932b0cb9f3ec - sourceBlobDigest: sha256:c06cc83921f8f24dfc098c977539857c3b7ff65302887ea14acb0fe3d5b17c62 + sourceRevisionDigest: sha256:85cedc03ea044870c54d91da42283ad4e3c44cf8e85f59025e281d46a59d8f04 + sourceBlobDigest: sha256:e5a801f69893464607a29d5b486de1f301d0ee4e5602dacf50ce3e9e5ba5c20a tags: - latest - main @@ -12,10 +12,10 @@ targets: speakeasy-client-sdk-go: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:09ff689e93c381070f346714a7fb3083f1a6bd568ef630b21db0932b0cb9f3ec - sourceBlobDigest: sha256:c06cc83921f8f24dfc098c977539857c3b7ff65302887ea14acb0fe3d5b17c62 + sourceRevisionDigest: sha256:85cedc03ea044870c54d91da42283ad4e3c44cf8e85f59025e281d46a59d8f04 + sourceBlobDigest: sha256:e5a801f69893464607a29d5b486de1f301d0ee4e5602dacf50ce3e9e5ba5c20a codeSamplesNamespace: code-samples-go-speakeasy-client-sdk-go - codeSamplesRevisionDigest: sha256:cd898ee6c6a4dc4ba10f7ae39c74773e067c9df95774c733dfe5994e12f7275f + codeSamplesRevisionDigest: sha256:4d8403c598860d338eaaa99bbd2144f234250a846e7682f43fbc50e3fd61ac89 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index 507d05a..4d91f9d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1596,4 +1596,14 @@ Based on: ### Generated - [go v3.21.0] . ### Releases -- [Go v3.21.0] https://github.com/speakeasy-api/speakeasy-client-sdk-go/releases/tag/v3.21.0 - . \ No newline at end of file +- [Go v3.21.0] https://github.com/speakeasy-api/speakeasy-client-sdk-go/releases/tag/v3.21.0 - . + +## 2025-01-31 22:02:19 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.481.1 (2.500.5) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v3.22.0] . +### Releases +- [Go v3.22.0] https://github.com/speakeasy-api/speakeasy-client-sdk-go/releases/tag/v3.22.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 3708941..6b3e99b 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -80,19 +80,19 @@ actions: x-codeSamples: - lang: go label: generateCodeSamplePreview - source: "package main\n\nimport(\n\t\"context\"\n\tspeakeasyclientsdkgo \"github.com/speakeasy-api/speakeasy-client-sdk-go/v3\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared\"\n\t\"os\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := speakeasyclientsdkgo.New(\n speakeasyclientsdkgo.WithSecurity(shared.Security{\n APIKey: speakeasyclientsdkgo.String(\"\"),\n }),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.CodeSamples.GenerateCodeSamplePreview(ctx, shared.CodeSampleSchemaInput{\n Languages: []string{\n \"\",\n \"\",\n },\n SchemaFile: shared.SchemaFile{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.TwoHundredApplicationXYamlResponseStream != nil {\n // handle response\n }\n}" + source: "package main\n\nimport(\n\t\"context\"\n\tspeakeasyclientsdkgo \"github.com/speakeasy-api/speakeasy-client-sdk-go/v3\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared\"\n\t\"os\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := speakeasyclientsdkgo.New(\n speakeasyclientsdkgo.WithSecurity(shared.Security{\n APIKey: speakeasyclientsdkgo.String(\"\"),\n }),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.CodeSamples.GenerateCodeSamplePreview(ctx, shared.CodeSampleSchemaInput{\n Language: \"\",\n SchemaFile: shared.SchemaFile{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.UsageSnippets != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/code_sample/preview/async"]["post"] update: x-codeSamples: - lang: go label: generateCodeSamplePreviewAsync - source: "package main\n\nimport(\n\t\"context\"\n\tspeakeasyclientsdkgo \"github.com/speakeasy-api/speakeasy-client-sdk-go/v3\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared\"\n\t\"os\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := speakeasyclientsdkgo.New(\n speakeasyclientsdkgo.WithSecurity(shared.Security{\n APIKey: speakeasyclientsdkgo.String(\"\"),\n }),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.CodeSamples.GenerateCodeSamplePreviewAsync(ctx, shared.CodeSampleSchemaInput{\n Languages: []string{\n \"\",\n \"\",\n \"\",\n },\n SchemaFile: shared.SchemaFile{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}" + source: "package main\n\nimport(\n\t\"context\"\n\tspeakeasyclientsdkgo \"github.com/speakeasy-api/speakeasy-client-sdk-go/v3\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared\"\n\t\"os\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := speakeasyclientsdkgo.New(\n speakeasyclientsdkgo.WithSecurity(shared.Security{\n APIKey: speakeasyclientsdkgo.String(\"\"),\n }),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.CodeSamples.GenerateCodeSamplePreviewAsync(ctx, shared.CodeSampleSchemaInput{\n Language: \"\",\n SchemaFile: shared.SchemaFile{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/code_sample/preview/async/{jobID}"]["get"] update: x-codeSamples: - lang: go label: getCodeSamplePreviewAsync - source: "package main\n\nimport(\n\t\"context\"\n\tspeakeasyclientsdkgo \"github.com/speakeasy-api/speakeasy-client-sdk-go/v3\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := speakeasyclientsdkgo.New(\n speakeasyclientsdkgo.WithSecurity(shared.Security{\n APIKey: speakeasyclientsdkgo.String(\"\"),\n }),\n )\n\n res, err := s.CodeSamples.GetCodeSamplePreviewAsync(ctx, operations.GetCodeSamplePreviewAsyncRequest{\n JobID: \"\",\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.TwoHundredApplicationXYamlResponseStream != nil {\n // handle response\n }\n}" + source: "package main\n\nimport(\n\t\"context\"\n\tspeakeasyclientsdkgo \"github.com/speakeasy-api/speakeasy-client-sdk-go/v3\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared\"\n\t\"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := speakeasyclientsdkgo.New(\n speakeasyclientsdkgo.WithSecurity(shared.Security{\n APIKey: speakeasyclientsdkgo.String(\"\"),\n }),\n )\n\n res, err := s.CodeSamples.GetCodeSamplePreviewAsync(ctx, operations.GetCodeSamplePreviewAsyncRequest{\n JobID: \"\",\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/github/action"]["get"] update: x-codeSamples: diff --git a/codesamples.go b/codesamples.go index f0c30ba..8de8215 100644 --- a/codesamples.go +++ b/codesamples.go @@ -41,7 +41,6 @@ func (s *CodeSamples) GenerateCodeSamplePreview(ctx context.Context, request sha supportedOptions := []string{ operations.SupportedOptionRetries, operations.SupportedOptionTimeout, - operations.SupportedOptionAcceptHeaderOverride, } for _, opt := range opts { @@ -81,12 +80,7 @@ func (s *CodeSamples) GenerateCodeSamplePreview(ctx context.Context, request sha if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } - if o.AcceptHeaderOverride != nil { - req.Header.Set("Accept", string(*o.AcceptHeaderOverride)) - } else { - req.Header.Set("Accept", "application/json;q=1, application/x-yaml;q=0") - } - + req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) if reqContentType != "" { req.Header.Set("Content-Type", reqContentType) @@ -196,16 +190,20 @@ func (s *CodeSamples) GenerateCodeSamplePreview(ctx context.Context, request sha } switch { - case httpRes.StatusCode == 200: + case httpRes.StatusCode >= 200 && httpRes.StatusCode < 300: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - res.TwoHundredApplicationJSONResponseStream = httpRes.Body + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } - return res, nil - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/x-yaml`): - res.TwoHundredApplicationXYamlResponseStream = httpRes.Body + var out shared.UsageSnippets + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } - return res, nil + res.UsageSnippets = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -738,7 +736,6 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope supportedOptions := []string{ operations.SupportedOptionRetries, operations.SupportedOptionTimeout, - operations.SupportedOptionAcceptHeaderOverride, } for _, opt := range opts { @@ -773,12 +770,7 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } - if o.AcceptHeaderOverride != nil { - req.Header.Set("Accept", string(*o.AcceptHeaderOverride)) - } else { - req.Header.Set("Accept", "application/json;q=1, application/x-yaml;q=0") - } - + req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { @@ -885,16 +877,20 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope } switch { - case httpRes.StatusCode == 200: + case httpRes.StatusCode == 202: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - res.TwoHundredApplicationJSONResponseStream = httpRes.Body + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } - return res, nil - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/x-yaml`): - res.TwoHundredApplicationXYamlResponseStream = httpRes.Body + var out operations.GetCodeSamplePreviewAsyncResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } - return res, nil + res.Object = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -902,7 +898,7 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope } return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } - case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 200 && httpRes.StatusCode < 300: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): rawBody, err := utils.ConsumeRawBody(httpRes) @@ -910,12 +906,12 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope return nil, err } - var out operations.GetCodeSamplePreviewAsyncResponseBody + var out shared.UsageSnippets if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.TwoHundredAndTwoApplicationJSONObject = &out + res.UsageSnippets = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { diff --git a/docs/pkg/models/operations/generatecodesamplepreviewresponse.md b/docs/pkg/models/operations/generatecodesamplepreviewresponse.md index e81c7cd..2778936 100644 --- a/docs/pkg/models/operations/generatecodesamplepreviewresponse.md +++ b/docs/pkg/models/operations/generatecodesamplepreviewresponse.md @@ -3,10 +3,9 @@ ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | -| `TwoHundredApplicationJSONResponseStream` | *io.ReadCloser* | :heavy_minus_sign: | Successfully returned codeSample overlay file | -| `TwoHundredApplicationXYamlResponseStream` | *io.ReadCloser* | :heavy_minus_sign: | Successfully returned codeSample overlay file | -| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | -| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | -| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `UsageSnippets` | [*shared.UsageSnippets](../../../pkg/models/shared/usagesnippets.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/docs/pkg/models/operations/getcodesamplepreviewasyncresponse.md b/docs/pkg/models/operations/getcodesamplepreviewasyncresponse.md index fa8b6d2..5252adc 100644 --- a/docs/pkg/models/operations/getcodesamplepreviewasyncresponse.md +++ b/docs/pkg/models/operations/getcodesamplepreviewasyncresponse.md @@ -5,9 +5,8 @@ | Field | Type | Required | Description | | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `TwoHundredApplicationJSONResponseStream` | *io.ReadCloser* | :heavy_minus_sign: | Successfully returned codeSample overlay file | -| `TwoHundredApplicationXYamlResponseStream` | *io.ReadCloser* | :heavy_minus_sign: | Successfully returned codeSample overlay file | -| `TwoHundredAndTwoApplicationJSONObject` | [*operations.GetCodeSamplePreviewAsyncResponseBody](../../../pkg/models/operations/getcodesamplepreviewasyncresponsebody.md) | :heavy_minus_sign: | Job is still in progress | | `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | | `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | -| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `UsageSnippets` | [*shared.UsageSnippets](../../../pkg/models/shared/usagesnippets.md) | :heavy_minus_sign: | OK | +| `Object` | [*operations.GetCodeSamplePreviewAsyncResponseBody](../../../pkg/models/operations/getcodesamplepreviewasyncresponsebody.md) | :heavy_minus_sign: | Job is still in progress | \ No newline at end of file diff --git a/docs/pkg/models/shared/codesampleschemainput.md b/docs/pkg/models/shared/codesampleschemainput.md index 45605a3..34f9c02 100644 --- a/docs/pkg/models/shared/codesampleschemainput.md +++ b/docs/pkg/models/shared/codesampleschemainput.md @@ -5,7 +5,8 @@ | Field | Type | Required | Description | | ------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- | -| `Languages` | []*string* | :heavy_check_mark: | A list of languages to generate code samples for | +| `Language` | *string* | :heavy_check_mark: | The language to generate code samples for | +| `OperationIds` | []*string* | :heavy_minus_sign: | A list of operations IDs to generate code samples for | | `PackageName` | **string* | :heavy_minus_sign: | The name of the package | | `SchemaFile` | [shared.SchemaFile](../../../pkg/models/shared/schemafile.md) | :heavy_check_mark: | The OpenAPI file to be uploaded | | `SDKClassName` | **string* | :heavy_minus_sign: | The SDK class name | \ No newline at end of file diff --git a/docs/sdks/codesamples/README.md b/docs/sdks/codesamples/README.md index 9bfb36b..535feac 100644 --- a/docs/sdks/codesamples/README.md +++ b/docs/sdks/codesamples/README.md @@ -45,10 +45,7 @@ func main() { res, err := s.CodeSamples.GenerateCodeSamplePreview(ctx, shared.CodeSampleSchemaInput{ - Languages: []string{ - "", - "", - }, + Language: "", SchemaFile: shared.SchemaFile{ Content: content, FileName: "example.file", @@ -57,7 +54,7 @@ func main() { if err != nil { log.Fatal(err) } - if res.TwoHundredApplicationJSONResponseStream != nil { + if res.UsageSnippets != nil { // handle response } } @@ -115,11 +112,7 @@ func main() { res, err := s.CodeSamples.GenerateCodeSamplePreviewAsync(ctx, shared.CodeSampleSchemaInput{ - Languages: []string{ - "", - "", - "", - }, + Language: "", SchemaFile: shared.SchemaFile{ Content: content, FileName: "example.file", @@ -255,7 +248,7 @@ func main() { if err != nil { log.Fatal(err) } - if res.TwoHundredApplicationJSONResponseStream != nil { + if res.Object != nil { // handle response } } diff --git a/gen.yaml b/gen.yaml index 33bdd6c..0770319 100644 --- a/gen.yaml +++ b/gen.yaml @@ -18,7 +18,7 @@ generation: tests: generateNewTests: true go: - version: 3.21.0 + version: 3.22.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/pkg/models/operations/generatecodesamplepreview.go b/pkg/models/operations/generatecodesamplepreview.go index 50d8071..ad1d8b8 100644 --- a/pkg/models/operations/generatecodesamplepreview.go +++ b/pkg/models/operations/generatecodesamplepreview.go @@ -3,37 +3,19 @@ package operations import ( - "io" + "github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared" "net/http" ) type GenerateCodeSamplePreviewResponse struct { - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationJSONResponseStream io.ReadCloser - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationXYamlResponseStream io.ReadCloser // HTTP response content type for this operation ContentType string // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response -} - -func (o *GenerateCodeSamplePreviewResponse) GetTwoHundredApplicationJSONResponseStream() io.ReadCloser { - if o == nil { - return nil - } - return o.TwoHundredApplicationJSONResponseStream -} - -func (o *GenerateCodeSamplePreviewResponse) GetTwoHundredApplicationXYamlResponseStream() io.ReadCloser { - if o == nil { - return nil - } - return o.TwoHundredApplicationXYamlResponseStream + // OK + UsageSnippets *shared.UsageSnippets } func (o *GenerateCodeSamplePreviewResponse) GetContentType() string { @@ -56,3 +38,10 @@ func (o *GenerateCodeSamplePreviewResponse) GetRawResponse() *http.Response { } return o.RawResponse } + +func (o *GenerateCodeSamplePreviewResponse) GetUsageSnippets() *shared.UsageSnippets { + if o == nil { + return nil + } + return o.UsageSnippets +} diff --git a/pkg/models/operations/getcodesamplepreviewasync.go b/pkg/models/operations/getcodesamplepreviewasync.go index a0a5539..2660cb8 100644 --- a/pkg/models/operations/getcodesamplepreviewasync.go +++ b/pkg/models/operations/getcodesamplepreviewasync.go @@ -4,7 +4,6 @@ package operations import ( "github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared" - "io" "net/http" ) @@ -34,60 +33,49 @@ func (o *GetCodeSamplePreviewAsyncResponseBody) GetStatus() shared.CodeSamplesJo } type GetCodeSamplePreviewAsyncResponse struct { - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationJSONResponseStream io.ReadCloser - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationXYamlResponseStream io.ReadCloser - // Job is still in progress - TwoHundredAndTwoApplicationJSONObject *GetCodeSamplePreviewAsyncResponseBody // HTTP response content type for this operation ContentType string // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response + // OK + UsageSnippets *shared.UsageSnippets + // Job is still in progress + Object *GetCodeSamplePreviewAsyncResponseBody } -func (o *GetCodeSamplePreviewAsyncResponse) GetTwoHundredApplicationJSONResponseStream() io.ReadCloser { +func (o *GetCodeSamplePreviewAsyncResponse) GetContentType() string { if o == nil { - return nil + return "" } - return o.TwoHundredApplicationJSONResponseStream + return o.ContentType } -func (o *GetCodeSamplePreviewAsyncResponse) GetTwoHundredApplicationXYamlResponseStream() io.ReadCloser { +func (o *GetCodeSamplePreviewAsyncResponse) GetStatusCode() int { if o == nil { - return nil + return 0 } - return o.TwoHundredApplicationXYamlResponseStream + return o.StatusCode } -func (o *GetCodeSamplePreviewAsyncResponse) GetTwoHundredAndTwoApplicationJSONObject() *GetCodeSamplePreviewAsyncResponseBody { +func (o *GetCodeSamplePreviewAsyncResponse) GetRawResponse() *http.Response { if o == nil { return nil } - return o.TwoHundredAndTwoApplicationJSONObject -} - -func (o *GetCodeSamplePreviewAsyncResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType + return o.RawResponse } -func (o *GetCodeSamplePreviewAsyncResponse) GetStatusCode() int { +func (o *GetCodeSamplePreviewAsyncResponse) GetUsageSnippets() *shared.UsageSnippets { if o == nil { - return 0 + return nil } - return o.StatusCode + return o.UsageSnippets } -func (o *GetCodeSamplePreviewAsyncResponse) GetRawResponse() *http.Response { +func (o *GetCodeSamplePreviewAsyncResponse) GetObject() *GetCodeSamplePreviewAsyncResponseBody { if o == nil { return nil } - return o.RawResponse + return o.Object } diff --git a/pkg/models/operations/options.go b/pkg/models/operations/options.go index 3ed3751..6a5b05c 100644 --- a/pkg/models/operations/options.go +++ b/pkg/models/operations/options.go @@ -24,7 +24,6 @@ const ( AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" AcceptHeaderEnumApplicationOctetStream AcceptHeaderEnum = "application/octet-stream" AcceptHeaderEnumApplicationVndOciImageManifestV1PlusJson AcceptHeaderEnum = "application/vnd.oci.image.manifest.v1+json" - AcceptHeaderEnumApplicationXYaml AcceptHeaderEnum = "application/x-yaml" ) func (e AcceptHeaderEnum) ToPointer() *AcceptHeaderEnum { diff --git a/pkg/models/shared/codesampleschemainput.go b/pkg/models/shared/codesampleschemainput.go index c86da80..5065af2 100644 --- a/pkg/models/shared/codesampleschemainput.go +++ b/pkg/models/shared/codesampleschemainput.go @@ -23,8 +23,10 @@ func (o *SchemaFile) GetFileName() string { } type CodeSampleSchemaInput struct { - // A list of languages to generate code samples for - Languages []string `multipartForm:"name=languages"` + // The language to generate code samples for + Language string `multipartForm:"name=language"` + // A list of operations IDs to generate code samples for + OperationIds []string `multipartForm:"name=operation_ids"` // The name of the package PackageName *string `multipartForm:"name=package_name"` // The OpenAPI file to be uploaded @@ -33,11 +35,18 @@ type CodeSampleSchemaInput struct { SDKClassName *string `multipartForm:"name=sdk_class_name"` } -func (o *CodeSampleSchemaInput) GetLanguages() []string { +func (o *CodeSampleSchemaInput) GetLanguage() string { if o == nil { - return []string{} + return "" + } + return o.Language +} + +func (o *CodeSampleSchemaInput) GetOperationIds() []string { + if o == nil { + return nil } - return o.Languages + return o.OperationIds } func (o *CodeSampleSchemaInput) GetPackageName() *string { diff --git a/speakeasy.go b/speakeasy.go index cbf256b..de05517 100644 --- a/speakeasy.go +++ b/speakeasy.go @@ -188,9 +188,9 @@ func New(opts ...SDKOption) *Speakeasy { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "0.4.0", - SDKVersion: "3.21.0", - GenVersion: "2.497.0", - UserAgent: "speakeasy-sdk/go 3.21.0 2.497.0 0.4.0 github.com/speakeasy-api/speakeasy-client-sdk-go", + SDKVersion: "3.22.0", + GenVersion: "2.500.5", + UserAgent: "speakeasy-sdk/go 3.22.0 2.500.5 0.4.0 github.com/speakeasy-api/speakeasy-client-sdk-go", Globals: globals.Globals{}, Hooks: hooks.New(), }, diff --git a/tests/mockserver/internal/handler/pathgetv1codesamplepreviewasyncjobid.go b/tests/mockserver/internal/handler/pathgetv1codesamplepreviewasyncjobid.go index 3a974b4..c6a6d83 100644 --- a/tests/mockserver/internal/handler/pathgetv1codesamplepreviewasyncjobid.go +++ b/tests/mockserver/internal/handler/pathgetv1codesamplepreviewasyncjobid.go @@ -46,7 +46,7 @@ func testGetCodeSamplePreviewAsyncGetCodeSamplePreviewAsync0(w http.ResponseWrit http.Error(w, err.Error(), http.StatusUnauthorized) return } - if err := assert.AcceptHeader(req, []string{"application/json;q=1", "application/x-yaml;q=0"}); err != nil { + if err := assert.AcceptHeader(req, []string{"application/json"}); err != nil { log.Printf("assertion error: %s\n", err) http.Error(w, err.Error(), http.StatusBadRequest) return diff --git a/tests/mockserver/internal/handler/pathpostv1codesamplepreview.go b/tests/mockserver/internal/handler/pathpostv1codesamplepreview.go index c79f0fe..eabd7af 100644 --- a/tests/mockserver/internal/handler/pathpostv1codesamplepreview.go +++ b/tests/mockserver/internal/handler/pathpostv1codesamplepreview.go @@ -6,7 +6,6 @@ import ( "fmt" "log" "mockserver/internal/handler/assert" - "mockserver/internal/handler/values" "mockserver/internal/logging" "mockserver/internal/tracking" "net/http" @@ -49,7 +48,7 @@ func testGenerateCodeSamplePreviewGenerateCodeSamplePreview0(w http.ResponseWrit http.Error(w, err.Error(), http.StatusBadRequest) return } - if err := assert.AcceptHeader(req, []string{"application/json;q=1", "application/x-yaml;q=0"}); err != nil { + if err := assert.AcceptHeader(req, []string{"application/json"}); err != nil { log.Printf("assertion error: %s\n", err) http.Error(w, err.Error(), http.StatusBadRequest) return @@ -59,8 +58,6 @@ func testGenerateCodeSamplePreviewGenerateCodeSamplePreview0(w http.ResponseWrit http.Error(w, err.Error(), http.StatusBadRequest) return } - respBodyBytes := values.ReadFileToBytes("./testdata/example.file") - w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) - _, _ = w.Write(respBodyBytes) } diff --git a/tests/mockserver/internal/sdk/models/components/codesampleschemainput.go b/tests/mockserver/internal/sdk/models/components/codesampleschemainput.go index c14364f..286a186 100644 --- a/tests/mockserver/internal/sdk/models/components/codesampleschemainput.go +++ b/tests/mockserver/internal/sdk/models/components/codesampleschemainput.go @@ -26,8 +26,10 @@ func (o *SchemaFile) GetFileName() string { } type CodeSampleSchemaInput struct { - // A list of languages to generate code samples for - Languages []string `multipartForm:"name=languages"` + // The language to generate code samples for + Language string `multipartForm:"name=language"` + // A list of operations IDs to generate code samples for + OperationIds []string `multipartForm:"name=operation_ids"` // The name of the package PackageName *string `multipartForm:"name=package_name"` // The OpenAPI file to be uploaded @@ -36,11 +38,18 @@ type CodeSampleSchemaInput struct { SDKClassName *string `multipartForm:"name=sdk_class_name"` } -func (o *CodeSampleSchemaInput) GetLanguages() []string { +func (o *CodeSampleSchemaInput) GetLanguage() string { if o == nil { - return []string{} + return "" + } + return o.Language +} + +func (o *CodeSampleSchemaInput) GetOperationIds() []string { + if o == nil { + return nil } - return o.Languages + return o.OperationIds } func (o *CodeSampleSchemaInput) GetPackageName() *string { diff --git a/tests/mockserver/internal/sdk/models/operations/generatecodesamplepreview.go b/tests/mockserver/internal/sdk/models/operations/generatecodesamplepreview.go index 8e78663..5495ee5 100644 --- a/tests/mockserver/internal/sdk/models/operations/generatecodesamplepreview.go +++ b/tests/mockserver/internal/sdk/models/operations/generatecodesamplepreview.go @@ -3,37 +3,25 @@ package operations import ( - "io" "mockserver/internal/sdk/models/components" ) type GenerateCodeSamplePreviewResponse struct { - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationJSONResponseStream io.ReadCloser - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationXYamlResponseStream io.ReadCloser - HTTPMeta components.HTTPMetadata `json:"-"` + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + UsageSnippets *components.UsageSnippets } -func (o *GenerateCodeSamplePreviewResponse) GetTwoHundredApplicationJSONResponseStream() io.ReadCloser { +func (o *GenerateCodeSamplePreviewResponse) GetHTTPMeta() components.HTTPMetadata { if o == nil { - return nil + return components.HTTPMetadata{} } - return o.TwoHundredApplicationJSONResponseStream + return o.HTTPMeta } -func (o *GenerateCodeSamplePreviewResponse) GetTwoHundredApplicationXYamlResponseStream() io.ReadCloser { +func (o *GenerateCodeSamplePreviewResponse) GetUsageSnippets() *components.UsageSnippets { if o == nil { return nil } - return o.TwoHundredApplicationXYamlResponseStream -} - -func (o *GenerateCodeSamplePreviewResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta + return o.UsageSnippets } diff --git a/tests/mockserver/internal/sdk/models/operations/getcodesamplepreviewasync.go b/tests/mockserver/internal/sdk/models/operations/getcodesamplepreviewasync.go index bc364aa..0e365fe 100644 --- a/tests/mockserver/internal/sdk/models/operations/getcodesamplepreviewasync.go +++ b/tests/mockserver/internal/sdk/models/operations/getcodesamplepreviewasync.go @@ -3,7 +3,6 @@ package operations import ( - "io" "mockserver/internal/sdk/models/components" ) @@ -33,41 +32,30 @@ func (o *GetCodeSamplePreviewAsyncResponseBody) GetStatus() components.CodeSampl } type GetCodeSamplePreviewAsyncResponse struct { - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationJSONResponseStream io.ReadCloser - // Successfully returned codeSample overlay file - // The Close method must be called on this field, even if it is not used, to prevent resource leaks. - TwoHundredApplicationXYamlResponseStream io.ReadCloser + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + UsageSnippets *components.UsageSnippets // Job is still in progress - TwoHundredAndTwoApplicationJSONObject *GetCodeSamplePreviewAsyncResponseBody - HTTPMeta components.HTTPMetadata `json:"-"` + Object *GetCodeSamplePreviewAsyncResponseBody } -func (o *GetCodeSamplePreviewAsyncResponse) GetTwoHundredApplicationJSONResponseStream() io.ReadCloser { +func (o *GetCodeSamplePreviewAsyncResponse) GetHTTPMeta() components.HTTPMetadata { if o == nil { - return nil + return components.HTTPMetadata{} } - return o.TwoHundredApplicationJSONResponseStream + return o.HTTPMeta } -func (o *GetCodeSamplePreviewAsyncResponse) GetTwoHundredApplicationXYamlResponseStream() io.ReadCloser { +func (o *GetCodeSamplePreviewAsyncResponse) GetUsageSnippets() *components.UsageSnippets { if o == nil { return nil } - return o.TwoHundredApplicationXYamlResponseStream + return o.UsageSnippets } -func (o *GetCodeSamplePreviewAsyncResponse) GetTwoHundredAndTwoApplicationJSONObject() *GetCodeSamplePreviewAsyncResponseBody { +func (o *GetCodeSamplePreviewAsyncResponse) GetObject() *GetCodeSamplePreviewAsyncResponseBody { if o == nil { return nil } - return o.TwoHundredAndTwoApplicationJSONObject -} - -func (o *GetCodeSamplePreviewAsyncResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta + return o.Object } diff --git a/tests/speakeasy_test.go b/tests/speakeasy_test.go index 43dcc74..d021d43 100644 --- a/tests/speakeasy_test.go +++ b/tests/speakeasy_test.go @@ -29,10 +29,7 @@ func TestSpeakeasy_GenerateCodeSamplePreview(t *testing.T) { require.NoError(t, fileErr) res, err := s.CodeSamples.GenerateCodeSamplePreview(ctx, shared.CodeSampleSchemaInput{ - Languages: []string{ - "", - "", - }, + Language: "", SchemaFile: shared.SchemaFile{ Content: content, FileName: "example.file", @@ -58,11 +55,7 @@ func TestSpeakeasy_GenerateCodeSamplePreviewAsync(t *testing.T) { require.NoError(t, fileErr) res, err := s.CodeSamples.GenerateCodeSamplePreviewAsync(ctx, shared.CodeSampleSchemaInput{ - Languages: []string{ - "", - "", - "", - }, + Language: "", SchemaFile: shared.SchemaFile{ Content: content, FileName: "example.file", @@ -94,9 +87,9 @@ func TestSpeakeasy_GetCodeSamplePreviewAsync(t *testing.T) { }) require.NoError(t, err) assert.Equal(t, 202, res.StatusCode) - assert.NotNil(t, res.TwoHundredAndTwoApplicationJSONObject) + assert.NotNil(t, res.Object) assert.Equal(t, &operations.GetCodeSamplePreviewAsyncResponseBody{ Status: shared.CodeSamplesJobStatusPending, - }, res.TwoHundredAndTwoApplicationJSONObject) + }, res.Object) }