Add support for override of property names
See original GitHub issueHi! Thank you for the great library!
Could you add support of overrided property names by attributes? For example, we have following model:
public class BestShot
{
[JsonProperty("photo")]
public string Link { get; set; }
[JsonProperty("zone")]
public string Area { get; set; }
}
Json properties are received from external system and can not be changed, but in our code we wish to work with more clear property names, so we use [JsonProperty]
attribute
In such case validation rules are not applied because they does not know about OpenAPI properties generated by attributes. The only place it could be done is inside FluentValidationRules
, but where istoo many internal stuff to override it
May be it could be done introducing some sort of map between .Net Property name and OpenAPI name like
new Dictionary<string, string>{{nameof(BestShot.Link), "photo"}}
attached to the type somewhere in AddFluentValidationRules
options
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - Overriding fields or properties in subclasses
Option 1: Use an abstract Property and override it on the inherited classes. This benefits from being enforced (you have to override it)...
Read more >override modifier - C# Reference
An overriding property declaration must specify exactly the same access modifier, type, and name as the inherited property.
Read more >Override a property
When you override a property on an event or property group, any changes to ... Navigate to the Events table and click on...
Read more >Using and Overriding Property Methods
To override the getter method for a property, modify the class that contains the property and add a method as follows: It must...
Read more >Property override configuration reference | Consul
This topic describes how to configure the property-override extension so that you can set and remove individual properties on the Envoy resources Consul ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
expected
, but validator works for theLink
property (as expected too) and does not know anything about property names in OpenAPIThe only place where mapping is possible is documentation filter - it knows about type and about open api schema. But we need to define mapping somehow - in dictionary or in other way (read from attribute for example).
Some interface which I could implement would be great
I’ll try a bit later. Next week possible