Create schema from generated code with inheritance.
#1 162 ouverte le 16 avr. 2020
Métriques du dépôt
- Stars
- (1 578 stars)
- Métriques de merge PR
- (Aucune PR mergée en 30 j)
Description
Hi,
I have special case, that causes issues.
I have a API with inheritance and a custom discriminator:
In short it looks like this:
[JsonConverter(typeof(TypedJsonInheritanceConverter<FieldPropertiesDto>), "fieldType")]
[KnownType(nameof(Subtypes))]
public abstract class FieldPropertiesDto
{
public static Type[] Subtypes()
{
return type.Assembly ...
}
}
As you can see, I have a custom converter, which derives from your InheritanceConverter and uses custom type names. This works fine, thanks to your awesome library.
From the API I generate a client library in C# and the output is like this:
[JsonConverter(typeof(JsonInheritanceConverter), new[] { "fieldType" })]
[JsonInheritanceAttribute("Array", typeof(ArrayFieldPropertiesDto))]]
public abstract class FieldPropertiesDto
{
}
}
The output is as expected. But this client library should be extended with an import feature, so I would like to use the generated code to create a json schema from it and I expect the result to be identical to the API schema.
But there are two issues:
-
The discriminator is
discriminatorinstead offieldType. I think the reason is that the generated JsonInheritanceConverter class does not contain aDiscriminatorNameproperty. This should be easy to fix. -
The type names are used instead of my custom names, e.g
ArrayFieldPropertiesDtoinstead ofArray. I don't know how to solve that.