Closed vincentparrett closed 6 years ago
I'm fine with adding a new attribute parameter to Model. I don't like the enum though, as it seems specific to your use case. Maybe something more like:
public enum PropertyVisibility = (
Public, //Just default to Public if the value is not supplied (that should prevent breaking)
PublicReadonly,
All //This is probably not needed
);
Feel free to rename them, but I would prefer them to be associated with the accesser modifiers (and not your use case)
Now that I think about it, perhaps all that is needed is a bool property ShowReadOnlyProps - this would be simple to implement and much less confusing to use.
That does sound better!
Implemented by #151
Expected Behavior
Read Model properties show in response models.
Actual Behavior
Only Model properties with public getter & setters show up.
Specifications
We have separate model types for reponses and requests, and pretty much all the properties on response models are read only, or the setters are protected. This means they are not shown in the swagger model.
Obviously, changing the behavior to allow read only properties would probably break existing projects, so my suggestion would be to add a ModelKind property to the ModelAttribute class,
The ModelKind property would default to Default, which would keep the existing behavior. ResponseOnly would allow read only properties, RequestOnly would behave the same as Default (read & write properties).
At the moment I'm totally blocked by this issue, happy to submit a pull request.