It seems that json converter ConfigureForNodaTime not work as expected on SchemaSettings, but work good on .NET Api json options. For example type Period not converted to string but as complex object similar to C# class. Nswag has a wrong behavior because correct conversion produce a string like described on NodaTime source code (https://github.com/nodatime/nodatime/blob/main/src/NodaTime/Text/PeriodPattern.cs#L70).
I write a workaround for this specific issue that map manually Period type:
if (document.SchemaSettings is SystemTextJsonSchemaGeneratorSettings schemaSettings)
{
schemaSettings.TypeMappers.Add(new PrimitiveTypeMapper(typeof(Period), s =>
{
s.Type = JsonObjectType.String;
s.Format = "period";
}));
}
but i expect that ConfigureForNodaTime work fine like other converters for example JsonStringEnumConverter.
After .NET 8 migration I move NSwag from v13 to v14. I have this Startup json api configuration:
It seems that json converter
ConfigureForNodaTime
not work as expected onSchemaSettings
, but work good on .NET Api json options. For example typePeriod
not converted to string but as complex object similar to C# class. Nswag has a wrong behavior because correct conversion produce a string like described on NodaTime source code (https://github.com/nodatime/nodatime/blob/main/src/NodaTime/Text/PeriodPattern.cs#L70).I write a workaround for this specific issue that map manually Period type:
but i expect that
ConfigureForNodaTime
work fine like other converters for exampleJsonStringEnumConverter
.