Skip to content

Commit

Permalink
Body properties default to null if annotated nullable.
Browse files Browse the repository at this point in the history
  • Loading branch information
smithgeek committed Dec 14, 2023
1 parent 94de7a5 commit 04fc4a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Voyager.SourceGenerator/VoyagerSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private string EndpointMapping(GeneratorExecutionContext context)
{
if (property.DataSource == ModelBindingSource.Body)
{
var defaultValue = property.DefaultValue ?? "default";
var defaultValue = property.DefaultValue ?? (property.Property.NullableAnnotation == NullableAnnotation.Annotated ? "null" : "default");
requestInit.AddStatement($"{property.Property.Name} = body?.{property.Name} ?? {defaultValue}{(property.Property.NullableAnnotation == NullableAnnotation.NotAnnotated ? "!" : "")},");
}
else if (property.DataSource == ModelBindingSource.Route
Expand Down

0 comments on commit 04fc4a2

Please sign in to comment.