azure-functions-openapi-extension
azure-functions-openapi-extension copied to clipboard
Fix handling of [JsonIgnore] to recurse and apply to inherited properties
Fix the handling of the Newtonsoft JsonIgnore attribute to take into account of inheritance.
@jstoker Thanks for the PR. Would you please be able to elaborate this PR?
Hi @justinyoo,
In one of our applications, we have a set of request/response types have a common set of properties, which are extracted into a common interface. One of the properties happens to be [JsonIgnore]-ed, as it isn't used by our client application, but generated within our functions code.
Newtonsoft JSON recognises the [JsonIgnore] attribute within the interface, and the Thing class when serialized will not contain the 'IgnoredProperty' in the JSON.
public interface IThing
{
[JsonIgnore]
string? IgnoredProperty { get; set; }
}
public class Thing : IThing
{
public string? IgnoredProperty { get; set; }
}
This PR is to make the behaviour of the OpenAPI generator not emit the IgnoredField in the swagger definition to correspond with the Newtonsoft behaviour (https://stackoverflow.com/a/55522993).