RicoSuter/NSwag

Support JsonSchemaAttribute on property/field

ggrossetie opened this issue · 0 comments

As mentioned in #706 it's possible to define the JsonSchemaAttribute annotation on a class:

public class ObjectFound
{
    public ReferenceId ReferenceId { get; set; }
}

[JsonSchema(JsonObjectType.String, Format = "guid")]
public record ReferenceId(string Value);

However, the same type (in this case ReferenceId) can be serialized differently:

public class Result
{
    [property: JsonConverter(typeof(ReferenceIdJsonConverter))]
    [JsonSchema(JsonObjectType.String, Format = "guid")]
    public ReferenceId ReferenceId { get; set; }
}

public class Request
{
    public ReferenceId ReferenceId { get; set; }
}

public record ReferenceId(string Value);

I think it would be great to support JsonSchemaAttribute on properties/fields to override the declared type.