forked from loafle/openapi-generator-original
[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:
parent
6434c86afd
commit
dad677f63d
@ -140,19 +140,21 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T{{nrt?}} AsModel(System.Text.Json.JsonSerializerOptions{{nrt?}} options = null)
|
||||
public T{{nrt?}} AsModel()
|
||||
{
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{>AsModel}}
|
||||
{{/lambda.trimTrailingWithNewLine}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </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
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
@ -1,4 +1,4 @@
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
@ -144,22 +144,22 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T AsModel(System.Text.Json.JsonSerializerOptions options = null)
|
||||
public T AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T model, System.Text.Json.JsonSerializerOptions options = null)
|
||||
public bool TryToModel([NotNullWhen(true)] out T model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
@ -146,22 +146,22 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T? AsModel(System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model, System.Text.Json.JsonSerializerOptions? options = null)
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
@ -144,22 +144,22 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T AsModel(System.Text.Json.JsonSerializerOptions options = null)
|
||||
public T AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, options ?? _jsonSerializerOptions)
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel(out T model, System.Text.Json.JsonSerializerOptions options = null)
|
||||
public bool TryToModel(out T model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel(options);
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
|
Loading…
x
Reference in New Issue
Block a user