Skip to content

Commit

Permalink
Merge pull request #448 from serverlessworkflow/fix-dashboard-seriali…
Browse files Browse the repository at this point in the history
…zation-identation

Fixed the default global JsonSerializer options by enforcing indentation
  • Loading branch information
cdavernas authored Oct 30, 2024
2 parents e7c6310 + bd9de3e commit b71dfe7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/dashboard/Synapse.Dashboard/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@
using ServerlessWorkflow.Sdk.Validation;
using System.Text.Json;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
var defaultPropertyNameResolver = ValidatorOptions.Global.PropertyNameResolver;
ValidatorOptions.Global.PropertyNameResolver = (type, member, lambda) =>
{
return member == null ? defaultPropertyNameResolver(type, member, lambda) : member.Name.ToCamelCase();
};
var defaultSerializationOptionsConfiguration = Neuroglia.Serialization.Json.JsonSerializer.DefaultOptionsConfiguration;
Neuroglia.Serialization.Json.JsonSerializer.DefaultOptionsConfiguration = (options) =>
{
defaultSerializationOptionsConfiguration(options);
options.WriteIndented = true;
};

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddLogging();
Expand Down Expand Up @@ -53,11 +64,6 @@
/* From AddServerlessWorkflowValidation */
builder.Services.AddScoped<IWorkflowDefinitionValidator, WorkflowDefinitionValidator>();
builder.Services.AddValidatorsFromAssemblyContaining<WorkflowDefinition>();
var defaultPropertyNameResolver = ValidatorOptions.Global.PropertyNameResolver;
ValidatorOptions.Global.PropertyNameResolver = (type, member, lambda) =>
{
return member == null ? defaultPropertyNameResolver(type, member, lambda) : member.Name.ToCamelCase();
};
/* End of AddServerlessWorkflowValidation */
builder.Services.AddSingleton<IMonacoEditorHelper, MonacoEditorHelper>();
builder.Services.AddScoped<IApplicationLayout, ApplicationLayout>();
Expand Down

0 comments on commit b71dfe7

Please sign in to comment.