Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Jackson Annotations for getters and setters also for Micronaut Serde #16966

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ Declare the class with extends and implements
{{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}} @JsonIgnore
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#jackson}}
{{>common/model/jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}} public {{#useOptional}}{{^required}}Optional<{{/required}}{{/useOptional}}{{{datatypeWithEnum}}}{{#useOptional}}{{^required}}>{{/required}}{{/useOptional}} {{getter}}() {
{{>common/model/jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}} public {{#useOptional}}{{^required}}Optional<{{/required}}{{/useOptional}}{{{datatypeWithEnum}}}{{#useOptional}}{{^required}}>{{/required}}{{/useOptional}} {{getter}}() {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
{{#isReadOnly}}
{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}} if ({{name}} == null) {
Expand Down Expand Up @@ -237,10 +236,9 @@ Declare the class with extends and implements

{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^isReadOnly}}
{{#jackson}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{>common/model/jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{#vendorExtensions.x-setter-extra-annotation}} {{{vendorExtensions.x-setter-extra-annotation}}}
{{/vendorExtensions.x-setter-extra-annotation}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{/vendorExtensions.x-setter-extra-annotation}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
{{/vendorExtensions.x-is-jackson-optional-nullable}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ paths:
schema:
enum:
- 1
- -2
- null
format: int32
type: integer
style: form
Expand Down Expand Up @@ -1650,13 +1650,13 @@ components:
enum_integer:
enum:
- 1
- -1
- null
format: int32
type: integer
enum_integer_only:
enum:
- 2
- -2
- null
type: integer
enum_number:
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@
NUMBER_1 = 1,

/// <summary>
/// Enum NUMBER_MINUS_1 for value: -1
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_1 = -1
NUMBER_null = null

Check failure on line 210 in samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net clients (samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 210 in samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net clients (samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/)

Cannot convert null to 'int' because it is a non-nullable value type
}


Expand Down Expand Up @@ -247,9 +247,9 @@
NUMBER_2 = 2,

/// <summary>
/// Enum NUMBER_MINUS_2 for value: -2
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_2 = -2
NUMBER_null = null

Check failure on line 252 in samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net clients (samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 252 in samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net clients (samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/)

Cannot convert null to 'int' because it is a non-nullable value type
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ paths:
schema:
enum:
- 1
- -2
- null
format: int32
type: integer
style: form
Expand Down Expand Up @@ -1650,13 +1650,13 @@ components:
enum_integer:
enum:
- 1
- -1
- null
format: int32
type: integer
enum_integer_only:
enum:
- 2
- -2
- null
type: integer
enum_number:
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
NUMBER_1 = 1,

/// <summary>
/// Enum NUMBER_MINUS_1 for value: -1
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_1 = -1
NUMBER_null = null

Check failure on line 77 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 77 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type
}

/// <summary>
Expand All @@ -88,8 +88,8 @@
if (value.Equals((1).ToString()))
return EnumIntegerEnum.NUMBER_1;

if (value.Equals((-1).ToString()))
return EnumIntegerEnum.NUMBER_MINUS_1;
if (value.Equals((null).ToString()))
return EnumIntegerEnum.NUMBER_null;

throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'");
}
Expand All @@ -104,8 +104,8 @@
if (value.Equals((1).ToString()))
return EnumIntegerEnum.NUMBER_1;

if (value.Equals((-1).ToString()))
return EnumIntegerEnum.NUMBER_MINUS_1;
if (value.Equals((null).ToString()))
return EnumIntegerEnum.NUMBER_null;

return null;
}
Expand Down Expand Up @@ -137,9 +137,9 @@
NUMBER_2 = 2,

/// <summary>
/// Enum NUMBER_MINUS_2 for value: -2
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_2 = -2
NUMBER_null = null

Check failure on line 142 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 142 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type
}

/// <summary>
Expand All @@ -153,8 +153,8 @@
if (value.Equals((2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_2;

if (value.Equals((-2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_MINUS_2;
if (value.Equals((null).ToString()))
return EnumIntegerOnlyEnum.NUMBER_null;

throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'");
}
Expand All @@ -169,8 +169,8 @@
if (value.Equals((2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_2;

if (value.Equals((-2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_MINUS_2;
if (value.Equals((null).ToString()))
return EnumIntegerOnlyEnum.NUMBER_null;

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ paths:
schema:
enum:
- 1
- -2
- null
format: int32
type: integer
style: form
Expand Down Expand Up @@ -1650,13 +1650,13 @@ components:
enum_integer:
enum:
- 1
- -1
- null
format: int32
type: integer
enum_integer_only:
enum:
- 2
- -2
- null
type: integer
enum_number:
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
NUMBER_1 = 1,

/// <summary>
/// Enum NUMBER_MINUS_1 for value: -1
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_1 = -1
NUMBER_null = null

Check failure on line 75 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 75 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 75 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 75 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt)

Cannot convert null to 'int' because it is a non-nullable value type
}

/// <summary>
Expand All @@ -86,8 +86,8 @@
if (value.Equals((1).ToString()))
return EnumIntegerEnum.NUMBER_1;

if (value.Equals((-1).ToString()))
return EnumIntegerEnum.NUMBER_MINUS_1;
if (value.Equals((null).ToString()))
return EnumIntegerEnum.NUMBER_null;

throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'");
}
Expand All @@ -102,8 +102,8 @@
if (value.Equals((1).ToString()))
return EnumIntegerEnum.NUMBER_1;

if (value.Equals((-1).ToString()))
return EnumIntegerEnum.NUMBER_MINUS_1;
if (value.Equals((null).ToString()))
return EnumIntegerEnum.NUMBER_null;

return null;
}
Expand Down Expand Up @@ -135,9 +135,9 @@
NUMBER_2 = 2,

/// <summary>
/// Enum NUMBER_MINUS_2 for value: -2
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_2 = -2
NUMBER_null = null

Check failure on line 140 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 140 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 140 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 140 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt)

Cannot convert null to 'int' because it is a non-nullable value type
}

/// <summary>
Expand All @@ -151,8 +151,8 @@
if (value.Equals((2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_2;

if (value.Equals((-2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_MINUS_2;
if (value.Equals((null).ToString()))
return EnumIntegerOnlyEnum.NUMBER_null;

throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'");
}
Expand All @@ -167,8 +167,8 @@
if (value.Equals((2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_2;

if (value.Equals((-2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_MINUS_2;
if (value.Equals((null).ToString()))
return EnumIntegerOnlyEnum.NUMBER_null;

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ paths:
schema:
enum:
- 1
- -2
- null
format: int32
type: integer
style: form
Expand Down Expand Up @@ -1650,13 +1650,13 @@ components:
enum_integer:
enum:
- 1
- -1
- null
format: int32
type: integer
enum_integer_only:
enum:
- 2
- -2
- null
type: integer
enum_number:
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
NUMBER_1 = 1,

/// <summary>
/// Enum NUMBER_MINUS_1 for value: -1
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_1 = -1
NUMBER_null = null

Check failure on line 73 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 73 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0)

Cannot convert null to 'int' because it is a non-nullable value type
}

/// <summary>
Expand All @@ -84,8 +84,8 @@
if (value.Equals((1).ToString()))
return EnumIntegerEnum.NUMBER_1;

if (value.Equals((-1).ToString()))
return EnumIntegerEnum.NUMBER_MINUS_1;
if (value.Equals((null).ToString()))
return EnumIntegerEnum.NUMBER_null;

throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'");
}
Expand All @@ -100,8 +100,8 @@
if (value.Equals((1).ToString()))
return EnumIntegerEnum.NUMBER_1;

if (value.Equals((-1).ToString()))
return EnumIntegerEnum.NUMBER_MINUS_1;
if (value.Equals((null).ToString()))
return EnumIntegerEnum.NUMBER_null;

return null;
}
Expand Down Expand Up @@ -133,9 +133,9 @@
NUMBER_2 = 2,

/// <summary>
/// Enum NUMBER_MINUS_2 for value: -2
/// Enum NUMBER_null for value: null
/// </summary>
NUMBER_MINUS_2 = -2
NUMBER_null = null

Check failure on line 138 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0)

Cannot convert null to 'int' because it is a non-nullable value type

Check failure on line 138 in samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs

View workflow job for this annotation

GitHub Actions / Build .Net projects (samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0)

Cannot convert null to 'int' because it is a non-nullable value type
}

/// <summary>
Expand All @@ -149,8 +149,8 @@
if (value.Equals((2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_2;

if (value.Equals((-2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_MINUS_2;
if (value.Equals((null).ToString()))
return EnumIntegerOnlyEnum.NUMBER_null;

throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'");
}
Expand All @@ -165,8 +165,8 @@
if (value.Equals((2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_2;

if (value.Equals((-2).ToString()))
return EnumIntegerOnlyEnum.NUMBER_MINUS_2;
if (value.Equals((null).ToString()))
return EnumIntegerOnlyEnum.NUMBER_null;

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ paths:
schema:
enum:
- 1
- -2
- null
format: int32
type: integer
style: form
Expand Down Expand Up @@ -1650,13 +1650,13 @@ components:
enum_integer:
enum:
- 1
- -1
- null
format: int32
type: integer
enum_integer_only:
enum:
- 2
- -2
- null
type: integer
enum_number:
enum:
Expand Down
Loading
Loading