Skip to content

Commit ae70f6e

Browse files
committed
fix: Fixed response deserialization when response type is just string.
1 parent a551442 commit ae70f6e

File tree

143 files changed

+143
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+143
-427
lines changed

src/libs/OpenApiGenerator.Core/Generation/Sources.Methods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static string GenerateMethod(
202202
}" : @"
203203
response.EnsureSuccessStatusCode();")}
204204
205-
{(endPoint.ContentType == ContentType.String ? $@"
205+
{(endPoint.ContentType == ContentType.String && endPoint.ResponseType.CSharpTypeWithoutNullability is not "string" ? $@"
206206
return
207207
{jsonSerializer.GenerateDeserializeCall(endPoint.ResponseType, endPoint.Settings.JsonSerializerContext)} ??
208208
throw new global::System.InvalidOperationException($""Response deserialization failed for \""{{__content}}\"" "");" : @"

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.RAGEngineClient.V1LibraryManagement4.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ partial void ProcessV1LibraryManagement4ResponseContent(
8282
throw new global::System.InvalidOperationException(__content, ex);
8383
}
8484

85-
return
86-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
87-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
85+
return __content;
8886
}
8987
}
9088
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/SystemTextJson/_#G.RAGEngineClient.V1LibraryManagement4.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ partial void ProcessV1LibraryManagement4ResponseContent(
8282
throw new global::System.InvalidOperationException(__content, ex);
8383
}
8484

85-
return
86-
global::System.Text.Json.JsonSerializer.Deserialize<string?>(__content, _jsonSerializerOptions) ??
87-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
85+
return __content;
8886
}
8987
}
9088
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.AccountClient.AccountGetExportStorageMetricsJobId.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ partial void ProcessAccountGetExportStorageMetricsJobIdResponseContent(
8888
throw new global::System.InvalidOperationException(__content, ex);
8989
}
9090

91-
return
92-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
93-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
91+
return __content;
9492
}
9593
}
9694
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.AccountClient.AccountSendPaymentReceipt.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ partial void ProcessAccountSendPaymentReceiptResponseContent(
100100
throw new global::System.InvalidOperationException(__content, ex);
101101
}
102102

103-
return
104-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
105-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
103+
return __content;
106104
}
107105
}
108106
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.AccountClient.AccountStartExportAccountChargesJob.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ partial void ProcessAccountStartExportAccountChargesJobResponseContent(
8888
throw new global::System.InvalidOperationException(__content, ex);
8989
}
9090

91-
return
92-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
93-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
91+
return __content;
9492
}
9593
}
9694
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.AccountClient.AccountStartExportAccountPaymentsJob.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ partial void ProcessAccountStartExportAccountPaymentsJobResponseContent(
8888
throw new global::System.InvalidOperationException(__content, ex);
8989
}
9090

91-
return
92-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
93-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
91+
return __content;
9492
}
9593
}
9694
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.AccountClient.AccountStartExportAccountProjectSummaryJob.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ partial void ProcessAccountStartExportAccountProjectSummaryJobResponseContent(
8888
throw new global::System.InvalidOperationException(__content, ex);
8989
}
9090

91-
return
92-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
93-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
91+
return __content;
9492
}
9593
}
9694
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.AccountClient.AccountStartGetAccountProjectInfoJob.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ partial void ProcessAccountStartGetAccountProjectInfoJobResponseContent(
8888
throw new global::System.InvalidOperationException(__content, ex);
8989
}
9090

91-
return
92-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
93-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
91+
return __content;
9492
}
9593
}
9694
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.DescriptorClient.DescriptorForceDeleteDescriptorSetPolled.g.verified.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ partial void ProcessDescriptorForceDeleteDescriptorSetPolledResponseContent(
9494
throw new global::System.InvalidOperationException(__content, ex);
9595
}
9696

97-
return
98-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<string?>(__content, _jsonSerializerOptions) ??
99-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
97+
return __content;
10098
}
10199
}
102100
}

0 commit comments

Comments
 (0)