ITADN

Allow setting JsonLibraryVersion

#1105OpenJappinen 创建于 2026-06-04
enhancement
J
Jappinencommented
With the NSwag being [updated to 14.7.0](https://github.com/christianhelle/refitter/pull/980) the NJsonSchema was also updated to 11.6.0 which included this change: - New JsonLibraryVersion setting for controlling enum attribute generation with System.Text.Json. If I'm understanding this correctly this should allow generating JsonStringEnumMemberName instead of ([or rather, in addition to](https://github.com/RicoSuter/NJsonSchema/pull/1905)) EnumMember for enum values: https://github.com/RicoSuter/NJsonSchema/blob/049c8c32d498b95fcd31e1289119ceb95ec52790/src/NJsonSchema.CodeGeneration.CSharp/Templates/Enum.liquid#L16 And with that we should be able to use the default implementation from framework starting from .NET 9 for the custom enum values: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/customize-properties#custom-enum-member-names **Additional thoughts** Again, [if I'm following this correctly](https://github.com/christianhelle/refitter/blob/5031b6699533d7bdb16a039e3d10bce90181b7a8/src/Refitter.Core/CSharpClientGeneratorFactory.cs#L364), Refitter maps some subset of settings of Refit settings - would it make sense to have some kind of an additional custom key-value dictionary configuration which would try to map from that dictionary to Refit settings any additional properties which the user might want to set? Obviously any type checking etc. would totally be best effort but that would allow trying NSwag/NJsonSchema settings that are not "officially" supported in Refitter.
0 条评论