Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

Hidden attribute on a method parameter does not hide parameter #47

Open
makotogitdev opened this issue Jan 15, 2014 · 2 comments
Open

Comments

@makotogitdev
Copy link
Collaborator

Even though you add a "[Hidden]" attribute to a method parameter, they are still visible in Swagger.

*You can work around by setting Hidden property of ParameterSettings attribute tag to true.

@tmcfarlane
Copy link

Is this a bug? I believe the intended function is that you use ParameterSettings for hiding the parameter.

Specifically, the functionality is here in the GetOperations method of the Mapper.cs:

//if the method is marked Hidden anywhere, skip it
                if (implementation.GetCustomAttribute <HiddenAttribute>() != null ||
                      declaration.GetCustomAttribute<HiddenAttribute>() != null) { continue; }

If you look a few blocks lower you'll see the parameter settings only picks up the ParameterSettingsAttribute:

var settings = implementation.GetParameters().First(p => p.Position.Equals(parameter.Position)).GetCustomAttribute<ParameterSettingsAttribute>() ??
                         parameter.GetCustomAttribute<ParameterSettingsAttribute>();

Edit: Where are the parameters visible in Swagger? I'm still getting familiar with the framework.

@makotogitdev
Copy link
Collaborator Author

I was thinking it would be nice to be able to use it on a parameter, not just on methods. Anyway maybe this is not really a bug like you said.

Method parameters should be visible between Response Class and Error code section. Here's an example from Swagger UI's demo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants