diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
index da64137b1844..bb27fe20f646 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
@@ -862,8 +862,8 @@ public void processOpts() {
@Override
public void setUseSourceGeneration(final Boolean useSourceGeneration) {
- if (useSourceGeneration && !this.additionalProperties.containsKey(NET_60_OR_LATER)) {
- throw new RuntimeException("Source generation is only compatible with .Net 6 or later.");
+ if (useSourceGeneration && !this.additionalProperties.containsKey(NET_70_OR_LATER)) {
+ throw new RuntimeException("Source generation is only compatible with .Net 7 or later.");
}
this.useSourceGeneration = useSourceGeneration;
}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache
index 292ea17cabd2..3a182e9f6946 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache
@@ -110,38 +110,8 @@ namespace {{packageName}}.{{clientPackage}}
///
/// The JsonSerialzierOptions
///
- private System.Text.Json.JsonSerializerOptions{{#useSourceGeneration}}{{nrt?}}{{/useSourceGeneration}} _jsonSerializerOptions;
+ private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
- {{#useSourceGeneration}}
- ///
- /// The JsonTypeInfo
- ///
- private readonly System.Text.Json.Serialization.Metadata.JsonTypeInfo{{nrt?}} _typeInfo;
-
- ///
- /// Construct the response using an HttpResponseMessage
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.Serialization.Metadata.JsonTypeInfo typeInfo)
- {
- StatusCode = httpResponseMessage.StatusCode;
- Headers = httpResponseMessage.Headers;
- IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
- ReasonPhrase = httpResponseMessage.ReasonPhrase;
- RawContent = rawContent;
- Path = path;
- RequestUri = httpRequestMessage.RequestUri;
- RequestedAt = requestedAt;
- _typeInfo = typeInfo;
- OnCreated(httpRequestMessage, httpResponseMessage);
- }
-
- {{/useSourceGeneration}}
///
/// Construct the response using an HttpResponseMessage
///
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache
index 4bffea0985d3..c4cc8d57a729 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache
@@ -1,14 +1,4 @@
// This logic may be modified with the AsModel.mustache template
- {{^useSourceGeneration}}
return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
: default(T);
- {{/useSourceGeneration}}
- {{#useSourceGeneration}}
- if (!IsSuccessStatusCode)
- return default(T);
-
- return _typeInfo == null
- ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : System.Text.Json.JsonSerializer.Deserialize(RawContent, _typeInfo);
- {{/useSourceGeneration}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
index 61c02557279a..1e848862a8bb 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
@@ -51,15 +51,23 @@ namespace {{packageName}}.{{clientPackage}}
{{#useSourceGeneration}}
{{#models}}
- {{#model}}
- _services.AddSingleton<{{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}SerializationContext>();
- {{/model}}
+ {{#-first}}
+ _jsonOptions.TypeInfoResolver = System.Text.Json.Serialization.Metadata.JsonTypeInfoResolver.Combine(
+ {{/-first}}
{{/models}}
-
+ {{#lambda.joinLinesWithComma}}
+ {{#models}}
+ {{#model}}
+ new {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}SerializationContext(){{#-last}},{{/-last}}
+ {{/model}}
+ {{/models}}
+ {{/lambda.joinLinesWithComma}}
{{#models}}
- {{#model}}
- _services.AddSingleton<{{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}DeserializationContext>();
- {{/model}}
+ {{#-last}}
+
+ new System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver()
+ );
+ {{/-last}}
{{/models}}
{{/useSourceGeneration}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/SourceGenerationContext.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/SourceGenerationContext.mustache
index 9e4612cfd891..b1798c98eb5e 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/SourceGenerationContext.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/SourceGenerationContext.mustache
@@ -3,32 +3,7 @@
///
/// The {{classname}}SerializationContext
///
- [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Serialization)]
+ [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)]
[JsonSerializable(typeof({{classname}}))]
- {{>visibility}} partial class {{classname}}SerializationContext : JsonSerializerContext
- {
- ///
- /// The {{classname}}SerializationContext
- ///
- ///
- public {{classname}}SerializationContext(JsonSerializerOptionsProvider optionsProvider): base(new(optionsProvider.Options))
- {
- }
- }
-
- ///
- /// {{classname}}DeserializationContext
- ///
- [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata)]
- [JsonSerializable(typeof({{classname}}))]
- {{>visibility}} partial class {{classname}}DeserializationContext : JsonSerializerContext
- {
- ///
- /// {{classname}}DeserializationContext
- ///
- ///
- public {{classname}}DeserializationContext(JsonSerializerOptionsProvider optionsProvider): base(new(optionsProvider.Options))
- {
- }
- }
+ {{>visibility}} partial class {{classname}}SerializationContext : JsonSerializerContext { }
{{/useSourceGeneration}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
index 03f273af3af0..305f76b5f7ae 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
@@ -103,19 +103,6 @@ namespace {{packageName}}.{{apiPackage}}
{{>visibility}} sealed partial class {{classname}} : {{interfacePrefix}}{{classname}}
{
private JsonSerializerOptions _jsonSerializerOptions;
- {{#useSourceGeneration}}
- {{#lambda.uniqueLinesWithNewLine}}
- {{#operation}}
- {{#returnProperty}}
- {{#isModel}}
- {{#returnType}}
- private {{{.}}}DeserializationContext _{{#lambda.camelcase_param}}{{{.}}}DeserializationContext{{/lambda.camelcase_param}};
- {{/returnType}}
- {{/isModel}}
- {{/returnProperty}}
- {{/operation}}
- {{/lambda.uniqueLinesWithNewLine}}
- {{/useSourceGeneration}}
///
/// The logger
@@ -161,24 +148,7 @@ namespace {{packageName}}.{{apiPackage}}
/// Initializes a new instance of the class.
///
///
- public {{classname}}(ILogger<{{classname}}> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, {{classname}}Events {{#lambda.camelcase_param}}{{classname}}Events{{/lambda.camelcase_param}}{{#lambda.first}}{{#useSourceGeneration}}{{#operation}}{{#returnProperty}}{{#isModel}}, {{/isModel}}{{/returnProperty}}{{/operation}}{{/useSourceGeneration}}{{/lambda.first}}{{#lambda.trimTrailing}}{{#useSourceGeneration}}
- {{#lambda.joinLinesWithComma}}
- {{#lambda.uniqueLinesWithNewLine}}
- {{#operation}}
- {{#returnProperty}}
- {{#isModel}}
- {{#returnType}}
- {{{.}}}DeserializationContext {{#lambda.camelcase_param}}{{{.}}}DeserializationContext{{/lambda.camelcase_param}}
- {{/returnType}}
- {{/isModel}}
- {{/returnProperty}}
- {{/operation}}
- {{/lambda.uniqueLinesWithNewLine}}
- {{/lambda.joinLinesWithComma}}
- {{/useSourceGeneration}}
- {{/lambda.trimTrailing}}
- {{#hasApiKeyMethods}}
-,
+ public {{classname}}(ILogger<{{classname}}> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, {{classname}}Events {{#lambda.camelcase_param}}{{classname}}Events{{/lambda.camelcase_param}}{{#hasApiKeyMethods}},
TokenProvider apiKeyProvider{{/hasApiKeyMethods}}{{#hasHttpBearerMethods}},
TokenProvider bearerTokenProvider{{/hasHttpBearerMethods}}{{#hasHttpBasicMethods}},
TokenProvider basicTokenProvider{{/hasHttpBasicMethods}}{{#hasHttpSignatureMethods}},
@@ -186,19 +156,6 @@ namespace {{packageName}}.{{apiPackage}}
TokenProvider oauthTokenProvider{{/hasOAuthMethods}})
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- {{#useSourceGeneration}}
- {{#lambda.uniqueLinesWithNewLine}}
- {{#operation}}
- {{#returnProperty}}
- {{#isModel}}
- {{#returnType}}
- _{{#lambda.camelcase_param}}{{{.}}}DeserializationContext{{/lambda.camelcase_param}} = {{#lambda.camelcase_param}}{{{.}}}DeserializationContext{{/lambda.camelcase_param}};
- {{/returnType}}
- {{/isModel}}
- {{/returnProperty}}
- {{/operation}}
- {{/lambda.uniqueLinesWithNewLine}}
- {{/useSourceGeneration}}
Logger = logger;
HttpClient = httpClient;
Events = {{#lambda.camelcase_param}}{{classname}}Events{{/lambda.camelcase_param}};{{#hasApiKeyMethods}}
@@ -582,7 +539,7 @@ namespace {{packageName}}.{{apiPackage}}
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync({{#net60OrLater}}cancellationToken{{/net60OrLater}}).ConfigureAwait(false);
- ApiResponse<{{{returnType}}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{path}}", requestedAtLocalVar, {{^useSourceGeneration}}_jsonSerializerOptions{{/useSourceGeneration}}{{#useSourceGeneration}}{{^returnProperty}}_jsonSerializerOptions{{/returnProperty}}{{#returnProperty}}{{^isModel}}_jsonSerializerOptions{{/isModel}}{{#isModel}}_{{#lambda.camelcase_param}}{{{returnType}}}DeserializationContext{{/lambda.camelcase_param}}.{{{returnType}}}{{/isModel}}{{/returnProperty}}{{/useSourceGeneration}});
+ ApiResponse<{{{returnType}}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{path}}", requestedAtLocalVar, _jsonSerializerOptions);
After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs
index daaec806fa37..4e25bc4a95cd 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs
@@ -15,6 +15,8 @@ public sealed class SerializationTests
{
private readonly IHost _host;
+ private readonly JsonSerializerOptions _jsonSerializerOptions;
+
public SerializationTests()
{
IHostBuilder hostBuild = Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) =>
@@ -42,17 +44,16 @@ public SerializationTests()
});
_host = hostBuild.Build();
+
+ _jsonSerializerOptions = _host.Services.GetRequiredService().Options;
}
[TestMethod]
public void Category()
{
- CategorySerializationContext serializationContext = _host.Services.GetRequiredService();
- CategoryDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
Category category = new(1, "test");
- string categoryJson = JsonSerializer.Serialize(category, serializationContext.Category);
- Category? category2 = JsonSerializer.Deserialize(categoryJson, deserializationContext.Category);
+ string categoryJson = JsonSerializer.Serialize(category, _jsonSerializerOptions);
+ Category? category2 = JsonSerializer.Deserialize(categoryJson, _jsonSerializerOptions);
Assert.AreEqual(category.Id, category2?.Id);
Assert.AreEqual(category.Name, category2?.Name);
}
@@ -60,25 +61,19 @@ public void Category()
[TestMethod]
public void Apple()
{
- AppleSerializationContext serializationContext = _host.Services.GetRequiredService();
- AppleDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
Apple apple = new("#000000", "cultivar", "origin");
- string appleJson = JsonSerializer.Serialize(apple, serializationContext.Apple);
- Apple? apple2 = JsonSerializer.Deserialize(appleJson, deserializationContext.Apple);
+ string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions);
+ Apple? apple2 = JsonSerializer.Deserialize(appleJson, _jsonSerializerOptions);
Assert.IsTrue(apple2 != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin.Equals(apple2.Origin));
}
[TestMethod]
public void Pig()
{
- PigSerializationContext serializationContext = _host.Services.GetRequiredService();
- PigDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
BasquePig basquePig = new("BasquePig");
Pig pig = new(basquePig, "BasquePig");
- string pigJson = JsonSerializer.Serialize(pig, serializationContext.Pig);
- Pig? pig2 = JsonSerializer.Deserialize(pigJson, deserializationContext.Pig);
+ string pigJson = JsonSerializer.Serialize(pig, _jsonSerializerOptions);
+ Pig? pig2 = JsonSerializer.Deserialize(pigJson, _jsonSerializerOptions);
Assert.IsTrue(
pig.DanishPig == null &&
pig.BasquePig != null &&
@@ -91,26 +86,20 @@ public void Pig()
[TestMethod]
public void DanishPig()
{
- DanishPigSerializationContext serializationContext = _host.Services.GetRequiredService();
- DanishPigDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
DanishPig danishPig = new("danishPig");
- string danishPigJson = JsonSerializer.Serialize(danishPig, serializationContext.DanishPig);
- DanishPig? danishPig2 = JsonSerializer.Deserialize(danishPigJson, deserializationContext.DanishPig);
+ string danishPigJson = JsonSerializer.Serialize(danishPig, _jsonSerializerOptions);
+ DanishPig? danishPig2 = JsonSerializer.Deserialize(danishPigJson, _jsonSerializerOptions);
Assert.IsTrue(danishPig2 != null && danishPig.ClassName.Equals(danishPig2.ClassName));
}
[TestMethod]
public void GmFruit()
{
- GmFruitSerializationContext serializationContext = _host.Services.GetRequiredService();
- GmFruitDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
Apple apple = new("#000000", "cultivar", "origin");
Banana banana = new(10);
GmFruit gmFruit = new(apple, banana, "yellow");
- string gmFruitJson = JsonSerializer.Serialize(gmFruit, serializationContext.GmFruit);
- GmFruit? gmFruit2 = JsonSerializer.Deserialize(gmFruitJson, deserializationContext.GmFruit);
+ string gmFruitJson = JsonSerializer.Serialize(gmFruit, _jsonSerializerOptions);
+ GmFruit? gmFruit2 = JsonSerializer.Deserialize(gmFruitJson, _jsonSerializerOptions);
Assert.IsTrue(
gmFruit.Apple != null &&
gmFruit.Banana != null &&
@@ -129,25 +118,19 @@ public void GmFruit()
[TestMethod]
public void EquilateralTriangle()
{
- EquilateralTriangleSerializationContext serializationContext = _host.Services.GetRequiredService();
- EquilateralTriangleDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
EquilateralTriangle equilateralTriangle = new("triangle", "equilateral");
- string equilateralTriangleJson = JsonSerializer.Serialize(equilateralTriangle, serializationContext.EquilateralTriangle);
- EquilateralTriangle? equilateralTriangle2 = JsonSerializer.Deserialize(equilateralTriangleJson, deserializationContext.EquilateralTriangle);
+ string equilateralTriangleJson = JsonSerializer.Serialize(equilateralTriangle, _jsonSerializerOptions);
+ EquilateralTriangle? equilateralTriangle2 = JsonSerializer.Deserialize(equilateralTriangleJson, _jsonSerializerOptions);
Assert.IsTrue(equilateralTriangle2 != null && equilateralTriangle.TriangleType.Equals(equilateralTriangle2.TriangleType) && equilateralTriangle.ShapeType.Equals(equilateralTriangle2.ShapeType));
}
[TestMethod]
public void Quadrilateral()
{
- QuadrilateralSerializationContext serializationContext = _host.Services.GetRequiredService();
- QuadrilateralDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
ComplexQuadrilateral complexQuadrilateral = new("ComplexQuadrilateral", "shapeType");
Quadrilateral quadrilateral = new(complexQuadrilateral, "ComplexQuadrilateral");
- string quadrilateralJson = JsonSerializer.Serialize(quadrilateral, serializationContext.Quadrilateral);
- Quadrilateral? quadrilateral2 = JsonSerializer.Deserialize(quadrilateralJson, deserializationContext.Quadrilateral);
+ string quadrilateralJson = JsonSerializer.Serialize(quadrilateral, _jsonSerializerOptions);
+ Quadrilateral? quadrilateral2 = JsonSerializer.Deserialize(quadrilateralJson, _jsonSerializerOptions);
Assert.IsTrue(
quadrilateral.ComplexQuadrilateral != null &&
quadrilateral2 != null &&
@@ -160,24 +143,18 @@ public void Quadrilateral()
[TestMethod]
public void ChildCatTest()
{
- ChildCatSerializationContext serializationContext = _host.Services.GetRequiredService();
- ChildCatDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
ChildCat childCat = new("some name", ChildCat.PetTypeEnum.ChildCat);
- string childCatJson = JsonSerializer.Serialize(childCat, serializationContext.ChildCat);
- ChildCat? childCat2 = JsonSerializer.Deserialize(childCatJson, deserializationContext.ChildCat);
+ string childCatJson = JsonSerializer.Serialize(childCat, _jsonSerializerOptions);
+ ChildCat? childCat2 = JsonSerializer.Deserialize(childCatJson, _jsonSerializerOptions);
Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name.Equals(childCat2.Name));
}
[TestMethod]
public void Cat()
{
- CatSerializationContext serializationContext = _host.Services.GetRequiredService();
- CatDeserializationContext deserializationContext = _host.Services.GetRequiredService();
-
Cat cat = new("cat", false, "black"); // TODO: where is the address property?
- string catJson = JsonSerializer.Serialize(cat, serializationContext.Cat);
- Cat? cat2 = JsonSerializer.Deserialize(catJson, deserializationContext.Cat);
+ string catJson = JsonSerializer.Serialize(cat, _jsonSerializerOptions);
+ Cat? cat2 = JsonSerializer.Deserialize(catJson, _jsonSerializerOptions);
Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color.Equals(cat2.Color)); // TODO: add the address property
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs
index cf6063040ffd..e22c4a0605f7 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs
@@ -92,7 +92,6 @@ internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception)
public sealed partial class AnotherFakeApi : IAnotherFakeApi
{
private JsonSerializerOptions _jsonSerializerOptions;
- private ModelClientDeserializationContext _modelClientDeserializationContext;
///
/// The logger
@@ -139,7 +138,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi
///
///
public AnotherFakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
- ModelClientDeserializationContext modelClientDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -147,7 +145,6 @@ public AnotherFakeApi(ILogger logger, HttpClient httpClient, Jso
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _modelClientDeserializationContext = modelClientDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = anotherFakeApiEvents;
@@ -291,7 +288,7 @@ public async Task> Call123TestSpecialTagsAsync(ModelCli
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _modelClientDeserializationContext.ModelClient);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs
index 6a7814a941d5..fad0e0c577c4 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs
@@ -256,8 +256,6 @@ internal void ExecuteOnErrorTest(Exception exception)
public sealed partial class DefaultApi : IDefaultApi
{
private JsonSerializerOptions _jsonSerializerOptions;
- private FooGetDefaultResponseDeserializationContext _fooGetDefaultResponseDeserializationContext;
- private NotificationtestGetElementsV1ResponseMPayloadDeserializationContext _notificationtestGetElementsV1ResponseMPayloadDeserializationContext;
///
/// The logger
@@ -304,8 +302,6 @@ public sealed partial class DefaultApi : IDefaultApi
///
///
public DefaultApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
- FooGetDefaultResponseDeserializationContext fooGetDefaultResponseDeserializationContext,
- NotificationtestGetElementsV1ResponseMPayloadDeserializationContext notificationtestGetElementsV1ResponseMPayloadDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -313,8 +309,6 @@ public DefaultApi(ILogger logger, HttpClient httpClient, JsonSeriali
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _fooGetDefaultResponseDeserializationContext = fooGetDefaultResponseDeserializationContext;
- _notificationtestGetElementsV1ResponseMPayloadDeserializationContext = notificationtestGetElementsV1ResponseMPayloadDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = defaultApiEvents;
@@ -422,7 +416,7 @@ public async Task> FooGetAsync(System.Threadi
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _fooGetDefaultResponseDeserializationContext.FooGetDefaultResponse);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
AfterFooGetDefaultImplementation(apiResponseLocalVar);
@@ -915,7 +909,7 @@ public async Task> Te
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _notificationtestGetElementsV1ResponseMPayloadDeserializationContext.NotificationtestGetElementsV1ResponseMPayload);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
AfterTestDefaultImplementation(apiResponseLocalVar);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs
index 0e32bae17000..d1d53093f5b7 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs
@@ -762,9 +762,6 @@ internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception excepti
public sealed partial class FakeApi : IFakeApi
{
private JsonSerializerOptions _jsonSerializerOptions;
- private HealthCheckResultDeserializationContext _healthCheckResultDeserializationContext;
- private OuterCompositeDeserializationContext _outerCompositeDeserializationContext;
- private ModelClientDeserializationContext _modelClientDeserializationContext;
///
/// The logger
@@ -811,9 +808,6 @@ public sealed partial class FakeApi : IFakeApi
///
///
public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents,
- HealthCheckResultDeserializationContext healthCheckResultDeserializationContext,
- OuterCompositeDeserializationContext outerCompositeDeserializationContext,
- ModelClientDeserializationContext modelClientDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -821,9 +815,6 @@ public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOpt
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _healthCheckResultDeserializationContext = healthCheckResultDeserializationContext;
- _outerCompositeDeserializationContext = outerCompositeDeserializationContext;
- _modelClientDeserializationContext = modelClientDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = fakeApiEvents;
@@ -931,7 +922,7 @@ public async Task> FakeHealthGetAsync(System.Thre
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _healthCheckResultDeserializationContext.HealthCheckResult);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions);
AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar);
@@ -1222,7 +1213,7 @@ public async Task> FakeOuterCompositeSerializeAsync(
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _outerCompositeDeserializationContext.OuterComposite);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions);
AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite);
@@ -2091,7 +2082,7 @@ public async Task> TestClientModelAsync(ModelClient mod
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _modelClientDeserializationContext.ModelClient);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions);
AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs
index 43825e1856ba..b89b8cc8b5ea 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs
@@ -92,7 +92,6 @@ internal void ExecuteOnErrorTestClassname(Exception exception)
public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api
{
private JsonSerializerOptions _jsonSerializerOptions;
- private ModelClientDeserializationContext _modelClientDeserializationContext;
///
/// The logger
@@ -139,7 +138,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api
///
///
public FakeClassnameTags123Api(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
- ModelClientDeserializationContext modelClientDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -147,7 +145,6 @@ public FakeClassnameTags123Api(ILogger logger, HttpClie
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _modelClientDeserializationContext = modelClientDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = fakeClassnameTags123ApiEvents;
@@ -302,7 +299,7 @@ public async Task> TestClassnameAsync(ModelClient model
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _modelClientDeserializationContext.ModelClient);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs
index 6ce306fc7db7..939b71c5cddd 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs
@@ -450,8 +450,6 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception)
public sealed partial class PetApi : IPetApi
{
private JsonSerializerOptions _jsonSerializerOptions;
- private PetDeserializationContext _petDeserializationContext;
- private ApiResponseDeserializationContext _apiResponseDeserializationContext;
///
/// The logger
@@ -498,8 +496,6 @@ public sealed partial class PetApi : IPetApi
///
///
public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents,
- PetDeserializationContext petDeserializationContext,
- ApiResponseDeserializationContext apiResponseDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -507,8 +503,6 @@ public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptio
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _petDeserializationContext = petDeserializationContext;
- _apiResponseDeserializationContext = apiResponseDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = petApiEvents;
@@ -1298,7 +1292,7 @@ public async Task> GetPetByIdAsync(long petId, System.Threading
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _petDeserializationContext.Pet);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions);
AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId);
@@ -1834,7 +1828,7 @@ public async Task> UploadFileAsync(long petId, Option apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _apiResponseDeserializationContext.ApiResponse);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions);
AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, file, additionalMetadata);
@@ -2022,7 +2016,7 @@ public async Task> UploadFileWithRequiredFileAsync(Syst
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _apiResponseDeserializationContext.ApiResponse);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions);
AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, requiredFile, petId, additionalMetadata);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs
index 78c789c85b7b..658e538224cf 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs
@@ -219,7 +219,6 @@ internal void ExecuteOnErrorPlaceOrder(Exception exception)
public sealed partial class StoreApi : IStoreApi
{
private JsonSerializerOptions _jsonSerializerOptions;
- private OrderDeserializationContext _orderDeserializationContext;
///
/// The logger
@@ -266,7 +265,6 @@ public sealed partial class StoreApi : IStoreApi
///
///
public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
- OrderDeserializationContext orderDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -274,7 +272,6 @@ public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerO
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _orderDeserializationContext = orderDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = storeApiEvents;
@@ -651,7 +648,7 @@ public async Task> GetOrderByIdAsync(long orderId, System.Thr
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _orderDeserializationContext.Order);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId);
@@ -803,7 +800,7 @@ public async Task> PlaceOrderAsync(Order order, System.Thread
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _orderDeserializationContext.Order);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs
index 48f91095f805..a4bc885856b9 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs
@@ -395,7 +395,6 @@ internal void ExecuteOnErrorUpdateUser(Exception exception)
public sealed partial class UserApi : IUserApi
{
private JsonSerializerOptions _jsonSerializerOptions;
- private UserDeserializationContext _userDeserializationContext;
///
/// The logger
@@ -442,7 +441,6 @@ public sealed partial class UserApi : IUserApi
///
///
public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents,
- UserDeserializationContext userDeserializationContext,
TokenProvider apiKeyProvider,
TokenProvider bearerTokenProvider,
TokenProvider basicTokenProvider,
@@ -450,7 +448,6 @@ public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOpt
TokenProvider oauthTokenProvider)
{
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
- _userDeserializationContext = userDeserializationContext;
Logger = logger;
HttpClient = httpClient;
Events = userApiEvents;
@@ -1139,7 +1136,7 @@ public async Task> GetUserByNameAsync(string username, System.
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _userDeserializationContext.User);
+ ApiResponse apiResponseLocalVar = new ApiResponse(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions);
AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ApiResponse`1.cs
index 72cffa4c55cb..96d5e92383e5 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ApiResponse`1.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ApiResponse`1.cs
@@ -116,35 +116,7 @@ public Type ResponseType
///
/// The JsonSerialzierOptions
///
- private System.Text.Json.JsonSerializerOptions? _jsonSerializerOptions;
-
- ///
- /// The JsonTypeInfo
- ///
- private readonly System.Text.Json.Serialization.Metadata.JsonTypeInfo? _typeInfo;
-
- ///
- /// Construct the response using an HttpResponseMessage
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.Serialization.Metadata.JsonTypeInfo typeInfo)
- {
- StatusCode = httpResponseMessage.StatusCode;
- Headers = httpResponseMessage.Headers;
- IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
- ReasonPhrase = httpResponseMessage.ReasonPhrase;
- RawContent = rawContent;
- Path = path;
- RequestUri = httpRequestMessage.RequestUri;
- RequestedAt = requestedAt;
- _typeInfo = typeInfo;
- OnCreated(httpRequestMessage, httpResponseMessage);
- }
+ private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
///
/// Construct the response using an HttpResponseMessage
@@ -177,12 +149,9 @@ public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System
public T? AsModel()
{
// This logic may be modified with the AsModel.mustache template
- if (!IsSuccessStatusCode)
- return default(T);
-
- return _typeInfo == null
+ return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : System.Text.Json.JsonSerializer.Deserialize(RawContent, _typeInfo);
+ : default(T);
}
///
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs
index d49c84acdea2..e173927d9f76 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs
@@ -139,183 +139,97 @@ public HostConfiguration(IServiceCollection services)
JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider);
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
-
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton();
- _services.AddSingleton