@@ -41,7 +41,6 @@ func (s *CodeSamples) GenerateCodeSamplePreview(ctx context.Context, request sha
41
41
supportedOptions := []string {
42
42
operations .SupportedOptionRetries ,
43
43
operations .SupportedOptionTimeout ,
44
- operations .SupportedOptionAcceptHeaderOverride ,
45
44
}
46
45
47
46
for _ , opt := range opts {
@@ -81,12 +80,7 @@ func (s *CodeSamples) GenerateCodeSamplePreview(ctx context.Context, request sha
81
80
if err != nil {
82
81
return nil , fmt .Errorf ("error creating request: %w" , err )
83
82
}
84
- if o .AcceptHeaderOverride != nil {
85
- req .Header .Set ("Accept" , string (* o .AcceptHeaderOverride ))
86
- } else {
87
- req .Header .Set ("Accept" , "application/json;q=1, application/x-yaml;q=0" )
88
- }
89
-
83
+ req .Header .Set ("Accept" , "application/json" )
90
84
req .Header .Set ("User-Agent" , s .sdkConfiguration .UserAgent )
91
85
if reqContentType != "" {
92
86
req .Header .Set ("Content-Type" , reqContentType )
@@ -196,16 +190,20 @@ func (s *CodeSamples) GenerateCodeSamplePreview(ctx context.Context, request sha
196
190
}
197
191
198
192
switch {
199
- case httpRes .StatusCode == 200 :
193
+ case httpRes .StatusCode >= 200 && httpRes . StatusCode < 300 :
200
194
switch {
201
195
case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/json` ):
202
- res .TwoHundredApplicationJSONResponseStream = httpRes .Body
196
+ rawBody , err := utils .ConsumeRawBody (httpRes )
197
+ if err != nil {
198
+ return nil , err
199
+ }
203
200
204
- return res , nil
205
- case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/x-yaml` ):
206
- res .TwoHundredApplicationXYamlResponseStream = httpRes .Body
201
+ var out shared.UsageSnippets
202
+ if err := utils .UnmarshalJsonFromResponseBody (bytes .NewBuffer (rawBody ), & out , "" ); err != nil {
203
+ return nil , err
204
+ }
207
205
208
- return res , nil
206
+ res . UsageSnippets = & out
209
207
default :
210
208
rawBody , err := utils .ConsumeRawBody (httpRes )
211
209
if err != nil {
@@ -738,7 +736,6 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope
738
736
supportedOptions := []string {
739
737
operations .SupportedOptionRetries ,
740
738
operations .SupportedOptionTimeout ,
741
- operations .SupportedOptionAcceptHeaderOverride ,
742
739
}
743
740
744
741
for _ , opt := range opts {
@@ -773,12 +770,7 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope
773
770
if err != nil {
774
771
return nil , fmt .Errorf ("error creating request: %w" , err )
775
772
}
776
- if o .AcceptHeaderOverride != nil {
777
- req .Header .Set ("Accept" , string (* o .AcceptHeaderOverride ))
778
- } else {
779
- req .Header .Set ("Accept" , "application/json;q=1, application/x-yaml;q=0" )
780
- }
781
-
773
+ req .Header .Set ("Accept" , "application/json" )
782
774
req .Header .Set ("User-Agent" , s .sdkConfiguration .UserAgent )
783
775
784
776
if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
@@ -885,37 +877,41 @@ func (s *CodeSamples) GetCodeSamplePreviewAsync(ctx context.Context, request ope
885
877
}
886
878
887
879
switch {
888
- case httpRes .StatusCode == 200 :
880
+ case httpRes .StatusCode == 202 :
889
881
switch {
890
882
case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/json` ):
891
- res .TwoHundredApplicationJSONResponseStream = httpRes .Body
883
+ rawBody , err := utils .ConsumeRawBody (httpRes )
884
+ if err != nil {
885
+ return nil , err
886
+ }
892
887
893
- return res , nil
894
- case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/x-yaml` ):
895
- res .TwoHundredApplicationXYamlResponseStream = httpRes .Body
888
+ var out operations.GetCodeSamplePreviewAsyncResponseBody
889
+ if err := utils .UnmarshalJsonFromResponseBody (bytes .NewBuffer (rawBody ), & out , "" ); err != nil {
890
+ return nil , err
891
+ }
896
892
897
- return res , nil
893
+ res . Object = & out
898
894
default :
899
895
rawBody , err := utils .ConsumeRawBody (httpRes )
900
896
if err != nil {
901
897
return nil , err
902
898
}
903
899
return nil , sdkerrors .NewSDKError (fmt .Sprintf ("unknown content-type received: %s" , httpRes .Header .Get ("Content-Type" )), httpRes .StatusCode , string (rawBody ), httpRes )
904
900
}
905
- case httpRes .StatusCode == 202 :
901
+ case httpRes .StatusCode >= 200 && httpRes . StatusCode < 300 :
906
902
switch {
907
903
case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/json` ):
908
904
rawBody , err := utils .ConsumeRawBody (httpRes )
909
905
if err != nil {
910
906
return nil , err
911
907
}
912
908
913
- var out operations. GetCodeSamplePreviewAsyncResponseBody
909
+ var out shared. UsageSnippets
914
910
if err := utils .UnmarshalJsonFromResponseBody (bytes .NewBuffer (rawBody ), & out , "" ); err != nil {
915
911
return nil , err
916
912
}
917
913
918
- res .TwoHundredAndTwoApplicationJSONObject = & out
914
+ res .UsageSnippets = & out
919
915
default :
920
916
rawBody , err := utils .ConsumeRawBody (httpRes )
921
917
if err != nil {
0 commit comments