-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d00de3f
commit ffa1ea3
Showing
3 changed files
with
178 additions
and
41 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
.../Mapper.FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost> MapToFartingUnicorn_Tests_SingleField_BoolType_NonNullableOptional_Tests_BlogPost(JsonElement jsonElement, string[] path = null) | ||
{ | ||
if(path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
/*object*/ | ||
{ | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
} | ||
var obj = new FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isIsDraftPropertyDefined = jsonElement.TryGetProperty("IsDraft", out var jsonIsDraftProperty); | ||
if (isIsDraftPropertyDefined) | ||
{ | ||
// type = Boolean, isOption = True, isNullable = False | ||
if (jsonIsDraftProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
obj.IsDraft = new None<Boolean>(); | ||
} | ||
else if (jsonIsDraftProperty.ValueKind == JsonValueKind.True || jsonIsDraftProperty.ValueKind == JsonValueKind.False) | ||
{ | ||
obj.IsDraft = new Some<bool>(jsonIsDraftProperty.GetBoolean()); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "IsDraft"], "Boolean", jsonIsDraftProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
errors.Add(new RequiredPropertyMissingError([.. path, "IsDraft"])); | ||
} | ||
if(errors.Any()) | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...tor/Mapper.FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost> MapToFartingUnicorn_Tests_SingleField_BoolType_NullableOptional_Tests_BlogPost(JsonElement jsonElement, string[] path = null) | ||
{ | ||
if(path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
/*object*/ | ||
{ | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
} | ||
var obj = new FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isIsDraftPropertyDefined = jsonElement.TryGetProperty("IsDraft", out var jsonIsDraftProperty); | ||
if (isIsDraftPropertyDefined) | ||
{ | ||
// type = Boolean, isOption = True, isNullable = True | ||
if (jsonIsDraftProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
obj.IsDraft = new None<Boolean>(); | ||
} | ||
else if (jsonIsDraftProperty.ValueKind == JsonValueKind.True || jsonIsDraftProperty.ValueKind == JsonValueKind.False) | ||
{ | ||
obj.IsDraft = new Some<bool>(jsonIsDraftProperty.GetBoolean()); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "IsDraft"], "Boolean", jsonIsDraftProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
obj.IsDraft = null; | ||
} | ||
if(errors.Any()) | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters