Expected Behavior
I have class like this:
public class MyClass
{
[JsonIgnore]
[ModelProperty(Ignore = true)]
public string _isSeven { get; set; }
public bool IsSeven
{
get
{
return _isSeven == 'True';
}
set
{
_isSeven = value ? 'True' : 'False';
}
}
}
I expect including this class in the ModelCatalog to not totally bork the Nancy.Swagger /api-docs route. I also expect it not to add _isSeven into the Schema Properties, or at least to do so under a different name.
Taking a look at the relevant code, the object properties are normalized using member.Key.ToCamelCase(), which maps both IsSeven and _isSeven to the same string, isSeven.
While I understand (and enjoy) normalization to camelCase, in the project I am working on, it is the convention to name sometimes name an underlying property the same as the public property, but prefixing the name with an underscore, eg IsSeven and _isSeven to be ultra pedantic. At the very least, the [ModelProperty(Ignore = true)] ought to fix this behavior (the error message for which is obtuse), or another property.
I hesitate to introduce Nancy.Swagger to my colleagues when I know that they will eventually have their swagger docs broken after trying to include a particular model.
Steps to Reproduce the Problem
- Open Nancy.Swagger sample annotations project
- Add class as described above somewhere in the project.
- Add class to ModelCatalog.
- Attempt to access generated docs -- will not work
Specifications
- Version:
2.2.53-alpha through and including master
- Project:
Nancy.Swagger
- Platform: Windows, .NET 4.6.1; probably all
Thank you,
Sam Berney
Expected Behavior
I have class like this:
I expect including this class in the ModelCatalog to not totally bork the Nancy.Swagger
/api-docsroute. I also expect it not to add_isSeveninto the Schema Properties, or at least to do so under a different name.Taking a look at the relevant code, the object properties are normalized using
member.Key.ToCamelCase(), which maps bothIsSevenand_isSevento the same string,isSeven.While I understand (and enjoy) normalization to camelCase, in the project I am working on, it is the convention to name sometimes name an underlying property the same as the public property, but prefixing the name with an underscore, eg
IsSevenand_isSevento be ultra pedantic. At the very least, the[ModelProperty(Ignore = true)]ought to fix this behavior (the error message for which is obtuse), or another property.I hesitate to introduce Nancy.Swagger to my colleagues when I know that they will eventually have their swagger docs broken after trying to include a particular model.
Steps to Reproduce the Problem
Specifications
2.2.53-alphathrough and includingmasterNancy.SwaggerThank you,
Sam Berney