refitter
refitter copied to clipboard
Support custom format-mappings via Key-Value configuration
Is your feature request related to a problem? Please describe. Sending proprietary data types which have custom serialization attached to them is bothersome as we have to manually override the generated api contracts.
{
"type": "string",
"format": "date-time"
}
This will be mapped to DateTimeOffset
for example.
Currently it's easy to override the "format" on the server side. But it's impossible to override the client generation to make use of the newly acquired information.
Describe the solution you'd like
{
"type": "string",
"format": "my-date-time"
}
Having a way to override string:my-date-time
(imaginary syntax) generated output.
kind of like "dateType": "System.DateOnly" but for anything we need.
{
"codeGeneratorSettings": {
"typeOverrides": {
"string:my-date-time": "Domain.Specific.DataType"
}
}
}
in Theory this should be doable by overriding how CSharpClientGeneratorSettings.CodeGeneratorSettings.TypeNameGenerator
generates the type name
Describe alternatives you've considered overriding the format to make the api return an object with a property of type "object", which then allows use to use "anyObjectType": "System.Text.Json.JsonElement" to manually deserialize the type.
But this requires us to copy the used JsonSerializationOptions everywhere.
Additional context ~~...~~