Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modules/openapi-generator/src/main/resources/go/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,22 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err
}
return nil
}
// Fallback: text/plain responses may carry JSON-encoded error messages
// (e.g. gateway-timeout: Content-Type: text/plain; charset=utf-8 with JSON body).
if strings.HasPrefix(contentType, "text/plain") && json.Valid(b) {
if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok {
if err = unmarshalObj.UnmarshalJSON(b); err != nil {
return err
}
} else {
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
}
} else if err = json.Unmarshal(b, v); err != nil {
return err
}
return nil
}
return errors.New("undefined response type")
}

Expand Down
16 changes: 16 additions & 0 deletions samples/client/echo_api/go-external-refs/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions samples/client/echo_api/go/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions samples/client/others/go/oneof-anyof-required/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions samples/client/others/go/oneof-discriminator-lookup/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
}

var httpValues = HttpUtility.ParseQueryString(string.Empty);
#if (NETCOREAPP)
// On .NET 9+, ParseQueryString already URL-encodes values.
// Skip UrlEncode to prevent double-encoding that causes signature mismatches.
string framework = RuntimeInformation.FrameworkDescription;
bool skipUrlEncode = framework.StartsWith(".NET ") &&
int.TryParse(framework.Substring(5).Split('.')[0], out int major) && major >= 9;
#endif
foreach (var parameter in requestOptions.QueryParameters)
{
#if (NETCOREAPP)
string framework = RuntimeInformation.FrameworkDescription;
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
string key = skipUrlEncode ? parameter.Key : HttpUtility.UrlEncode(parameter.Key);
if (parameter.Value.Count > 1)
{ // array
foreach (var value in parameter.Value)
Expand Down
16 changes: 16 additions & 0 deletions samples/client/petstore/go/go-petstore/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading