[csharp][generichost] Remove unnecessary json options (#16483)

* started source generator

* copy the options

* fixed visibility

* added new sample

* discarded changes to existing samples

* discarded changes to existing samples

* build new sample

* changed package name due to file path length limit

* reverted changes to manual tests

* fixed all new manual tests

* inject contexts into api

* only one JsonConstructor

* fixed spacing

* revert samples for easier merge master

* revert unnecessary change

* fixed formatting

* build samples

* reverting unintended commit

* fixing default value

* reverting unintended commit

* removed unnecessary json option
This commit is contained in:
devhl-labs 2023-09-03 04:19:23 -04:00 committed by GitHub
parent 6434c86afd
commit dad677f63d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 28 deletions

View File

@ -140,19 +140,21 @@ namespace {{packageName}}.{{clientPackage}}
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T{{nrt?}} AsModel(System.Text.Json.JsonSerializerOptions{{nrt?}} options = null) public T{{nrt?}} AsModel()
{ {
{{#lambda.trimTrailingWithNewLine}}
{{>AsModel}} {{>AsModel}}
{{/lambda.trimTrailingWithNewLine}}
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel({{^netStandard}}[NotNullWhen(true)] {{/netStandard}}out T{{nrt?}} model, System.Text.Json.JsonSerializerOptions{{nrt?}} options = null) public bool TryToModel({{^netStandard}}[NotNullWhen(true)] {{/netStandard}}out T{{nrt?}} model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch

View File

@ -1,4 +1,4 @@
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);

View File

@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null) public T? AsModel()
{ {
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null) public bool TryToModel([NotNullWhen(true)] out T? model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch

View File

@ -144,22 +144,22 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T AsModel(System.Text.Json.JsonSerializerOptions options = null) public T AsModel()
{ {
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel([NotNullWhen(true)] out T model, System.Text.Json.JsonSerializerOptions options = null) public bool TryToModel([NotNullWhen(true)] out T model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch

View File

@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null) public T? AsModel()
{ {
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null) public bool TryToModel([NotNullWhen(true)] out T? model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch

View File

@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null) public T? AsModel()
{ {
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null) public bool TryToModel([NotNullWhen(true)] out T? model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch

View File

@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null) public T? AsModel()
{ {
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null) public bool TryToModel([NotNullWhen(true)] out T? model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch

View File

@ -144,22 +144,22 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Deserializes the server's response /// Deserializes the server's response
/// </summary> /// </summary>
public T AsModel(System.Text.Json.JsonSerializerOptions options = null) public T AsModel()
{ {
// This logic may be modified with the AsModel.mustache template // This logic may be modified with the AsModel.mustache template
return IsSuccessStatusCode return IsSuccessStatusCode
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions) ? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
: default(T); : default(T);
} }
/// <summary> /// <summary>
/// Returns true when the model can be deserialized /// Returns true when the model can be deserialized
/// </summary> /// </summary>
public bool TryToModel(out T model, System.Text.Json.JsonSerializerOptions options = null) public bool TryToModel(out T model)
{ {
try try
{ {
model = AsModel(options); model = AsModel();
return model != null; return model != null;
} }
catch catch