-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow SwaggerResponse attribute at class level? #158
Comments
Yeah, it would be helpful. A function like this would allow it to work without changing the existing flow (or another extension method). private IEnumerable<T> GetCustomAttributes<T>(MethodInfo handler) where T: Attribute
{
var attributes = handler.GetCustomAttributes<T>();
return attributes.Concat(handler.DeclaringType.GetTypeInfo().GetCustomAttributes<T>());
} You would just need to replace the current GetCustomAttributes in AnnotatedOperation. Feel free to try and implement! Otherwise I'll get to it later. |
It's a bit more complicated than that, as you probably want to deal with duplicates for a start. |
True. There might be a response that you want for the whole module, but a certain route might want to override it. That could still be implemented using my code. Maybe just another method attribute that says to skip the class attributes. |
I think a duplicate response would be by status code and model. I think we should keep it simple, if it's on the class it's on all methods, otherwise you have to use method attributes. |
Currently, the SwaggerResponse is only valid for methods. As I get deeper into instrumenting my modules with the Nancy.Swagger attributes, I'm finding some modules have common attributes on every method, for example :
is on pretty much every method I have instrumented so far.
Would it make sense to allow the SwaggerResponse at the method level?
The text was updated successfully, but these errors were encountered: