Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arealmaas committed Oct 8, 2024
1 parent 8b8806d commit 353138e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Digdir.Domain.Dialogporten.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ static void BuildAndRun(string[] args)
.UseServiceOwnerOnBehalfOfPerson()
.UseUserTypeValidation()
.UseAzureConfiguration()
.UseFastEndpoints(x =>
{
x.Endpoints.RoutePrefix = "api";
x.Versioning.Prefix = "v";
x.Versioning.PrependToRoute = true;
x.Versioning.DefaultVersion = 1;
x.Serializer.Options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
// Do not serialize empty collections
x.Serializer.Options.TypeInfoResolver = new DefaultJsonTypeInfoResolver
{
Modifiers = { IgnoreEmptyCollections }
};
x.Serializer.Options.Converters.Add(new JsonStringEnumConverter());
x.Serializer.Options.Converters.Add(new UtcDateTimeOffsetConverter());
x.Serializer.Options.Converters.Add(new DateTimeNotSupportedConverter());
x.Errors.ResponseBuilder = ErrorResponseBuilderExtensions.ResponseBuilder;
})
.UseAddSwaggerCorsHeader()
.UseSwaggerGen(config =>
{
Expand All @@ -191,23 +208,6 @@ static void BuildAndRun(string[] args)
// We have to add dialogporten here to get the correct base url for swagger.json in the APIM. Should not be done for development
var dialogPrefix = builder.Environment.IsDevelopment() ? "" : "/dialogporten";
uiConfig.DocumentPath = dialogPrefix + "/swagger/{documentName}/swagger.json";
})
.UseFastEndpoints(x =>
{
x.Endpoints.RoutePrefix = "api";
x.Versioning.Prefix = "v";
x.Versioning.PrependToRoute = true;
x.Versioning.DefaultVersion = 1;
x.Serializer.Options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
// Do not serialize empty collections
x.Serializer.Options.TypeInfoResolver = new DefaultJsonTypeInfoResolver
{
Modifiers = { IgnoreEmptyCollections }
};
x.Serializer.Options.Converters.Add(new JsonStringEnumConverter());
x.Serializer.Options.Converters.Add(new UtcDateTimeOffsetConverter());
x.Serializer.Options.Converters.Add(new DateTimeNotSupportedConverter());
x.Errors.ResponseBuilder = ErrorResponseBuilderExtensions.ResponseBuilder;
});

app.Run();
Expand Down

0 comments on commit 353138e

Please sign in to comment.