-
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
b64953c
commit 0a7a1b3
Showing
5 changed files
with
531 additions
and
143 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...apperGenerator/Mapper.FartingUnicorn.Tests.MultipleFields.WithOptions.PATCH.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,81 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
using static FartingUnicorn.MapperOptions; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PATCH.BlogPost> MapToFartingUnicorn_Tests_MultipleFields_WithOptions_PATCH_BlogPost(JsonElement jsonElement, MapperOptions mapperOptions = null, string[] path = null) | ||
{ | ||
if (mapperOptions is null) | ||
{ | ||
mapperOptions = new MapperOptions(); | ||
} | ||
if (path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PATCH.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
var obj = new FartingUnicorn.Tests.MultipleFields.WithOptions.PATCH.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isCategoryPropertyDefined = jsonElement.TryGetProperty("Category", out var jsonCategoryProperty); | ||
if (isCategoryPropertyDefined) | ||
{ | ||
// type = System.String, isOption = True, isNullable = True | ||
if (jsonCategoryProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
obj.Category = new None<System.String>(); | ||
} | ||
else if (jsonCategoryProperty.ValueKind == JsonValueKind.String) | ||
{ | ||
obj.Category = new Some<string>(jsonCategoryProperty.GetString()); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "Category"], "String", jsonCategoryProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
obj.Category = null; | ||
} | ||
var isRatingPropertyDefined = jsonElement.TryGetProperty("Rating", out var jsonRatingProperty); | ||
if (isRatingPropertyDefined) | ||
{ | ||
// type = System.Int32, isOption = True, isNullable = True | ||
if (jsonRatingProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
obj.Rating = new None<System.Int32>(); | ||
} | ||
else if (jsonRatingProperty.ValueKind == JsonValueKind.Number) | ||
{ | ||
obj.Rating = new Some<int>(jsonRatingProperty.GetInt32()); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "Rating"], "Number", jsonRatingProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
obj.Rating = null; | ||
} | ||
if(errors.Any()) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PATCH.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PATCH.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
....MapperGenerator/Mapper.FartingUnicorn.Tests.MultipleFields.WithOptions.PUT.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,81 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
using static FartingUnicorn.MapperOptions; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PUT.BlogPost> MapToFartingUnicorn_Tests_MultipleFields_WithOptions_PUT_BlogPost(JsonElement jsonElement, MapperOptions mapperOptions = null, string[] path = null) | ||
{ | ||
if (mapperOptions is null) | ||
{ | ||
mapperOptions = new MapperOptions(); | ||
} | ||
if (path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PUT.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
var obj = new FartingUnicorn.Tests.MultipleFields.WithOptions.PUT.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isCategoryPropertyDefined = jsonElement.TryGetProperty("Category", out var jsonCategoryProperty); | ||
if (isCategoryPropertyDefined) | ||
{ | ||
// type = System.String, isOption = True, isNullable = False | ||
if (jsonCategoryProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
obj.Category = new None<System.String>(); | ||
} | ||
else if (jsonCategoryProperty.ValueKind == JsonValueKind.String) | ||
{ | ||
obj.Category = new Some<string>(jsonCategoryProperty.GetString()); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "Category"], "String", jsonCategoryProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
errors.Add(new RequiredPropertyMissingError([.. path, "Category"])); | ||
} | ||
var isRatingPropertyDefined = jsonElement.TryGetProperty("Rating", out var jsonRatingProperty); | ||
if (isRatingPropertyDefined) | ||
{ | ||
// type = System.Int32, isOption = True, isNullable = False | ||
if (jsonRatingProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
obj.Rating = new None<System.Int32>(); | ||
} | ||
else if (jsonRatingProperty.ValueKind == JsonValueKind.Number) | ||
{ | ||
obj.Rating = new Some<int>(jsonRatingProperty.GetInt32()); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "Rating"], "Number", jsonRatingProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
errors.Add(new RequiredPropertyMissingError([.. path, "Rating"])); | ||
} | ||
if(errors.Any()) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PUT.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithOptions.PUT.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...erGenerator/Mapper.FartingUnicorn.Tests.MultipleFields.WithoutOptions.PATCH.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,81 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
using static FartingUnicorn.MapperOptions; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PATCH.BlogPost> MapToFartingUnicorn_Tests_MultipleFields_WithoutOptions_PATCH_BlogPost(JsonElement jsonElement, MapperOptions mapperOptions = null, string[] path = null) | ||
{ | ||
if (mapperOptions is null) | ||
{ | ||
mapperOptions = new MapperOptions(); | ||
} | ||
if (path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PATCH.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
var obj = new FartingUnicorn.Tests.MultipleFields.WithoutOptions.PATCH.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isTitlePropertyDefined = jsonElement.TryGetProperty("Title", out var jsonTitleProperty); | ||
if (isTitlePropertyDefined) | ||
{ | ||
// type = System.String, isOption = False, isNullable = True | ||
if (jsonTitleProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
errors.Add(new RequiredValueMissingError([.. path, "Title"])); | ||
} | ||
else if (jsonTitleProperty.ValueKind == JsonValueKind.String) | ||
{ | ||
obj.Title = jsonTitleProperty.GetString(); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "Title"], "String", jsonTitleProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
obj.Title = null; | ||
} | ||
var isIsDraftPropertyDefined = jsonElement.TryGetProperty("IsDraft", out var jsonIsDraftProperty); | ||
if (isIsDraftPropertyDefined) | ||
{ | ||
// type = System.Boolean, isOption = False, isNullable = True | ||
if (jsonIsDraftProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
errors.Add(new RequiredValueMissingError([.. path, "IsDraft"])); | ||
} | ||
else if (jsonIsDraftProperty.ValueKind == JsonValueKind.True || jsonIsDraftProperty.ValueKind == JsonValueKind.False) | ||
{ | ||
obj.IsDraft = jsonIsDraftProperty.GetBoolean(); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "IsDraft"], "Boolean", jsonIsDraftProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
obj.IsDraft = null; | ||
} | ||
if(errors.Any()) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PATCH.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PATCH.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...pperGenerator/Mapper.FartingUnicorn.Tests.MultipleFields.WithoutOptions.PUT.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,81 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
using static FartingUnicorn.MapperOptions; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PUT.BlogPost> MapToFartingUnicorn_Tests_MultipleFields_WithoutOptions_PUT_BlogPost(JsonElement jsonElement, MapperOptions mapperOptions = null, string[] path = null) | ||
{ | ||
if (mapperOptions is null) | ||
{ | ||
mapperOptions = new MapperOptions(); | ||
} | ||
if (path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PUT.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
var obj = new FartingUnicorn.Tests.MultipleFields.WithoutOptions.PUT.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isTitlePropertyDefined = jsonElement.TryGetProperty("Title", out var jsonTitleProperty); | ||
if (isTitlePropertyDefined) | ||
{ | ||
// type = System.String, isOption = False, isNullable = False | ||
if (jsonTitleProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
errors.Add(new RequiredValueMissingError([.. path, "Title"])); | ||
} | ||
else if (jsonTitleProperty.ValueKind == JsonValueKind.String) | ||
{ | ||
obj.Title = jsonTitleProperty.GetString(); | ||
} | ||
else | ||
{ | ||
errors.Add(new ValueHasWrongTypeError([.. path, "Title"], "String", jsonTitleProperty.ValueKind.ToString())); | ||
} | ||
} | ||
else | ||
{ | ||
errors.Add(new RequiredPropertyMissingError([.. path, "Title"])); | ||
} | ||
var isIsDraftPropertyDefined = jsonElement.TryGetProperty("IsDraft", out var jsonIsDraftProperty); | ||
if (isIsDraftPropertyDefined) | ||
{ | ||
// type = System.Boolean, isOption = False, isNullable = False | ||
if (jsonIsDraftProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
errors.Add(new RequiredValueMissingError([.. path, "IsDraft"])); | ||
} | ||
else if (jsonIsDraftProperty.ValueKind == JsonValueKind.True || jsonIsDraftProperty.ValueKind == JsonValueKind.False) | ||
{ | ||
obj.IsDraft = 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.MultipleFields.WithoutOptions.PUT.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.MultipleFields.WithoutOptions.PUT.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
Oops, something went wrong.