Swashbuckle.webapi: Exclude controllers from docs without using the Obsolete attribute

Created on 25 Sep 2014  Â·  5Comments  Â·  Source: domaindrivendev/Swashbuckle.WebApi

Is it possible to exclude controllers/actions from the api docs without using the Obsolete attribute?
I don't want some actions included, but they are not obsolete in the meaning of the System.ObsoleteAttribute.

Thank you!

Most helpful comment

Just though of something ... Swashbuckle adds an adapter for generating Swagger on top of the built-in IAPIExplorer. As it happens, this does come with an attribute to ignore certain actions. If you apply it, IApiExplorer won't include a description for the action and as a result, neither will Swashbuckle.

public class ValuesController : ApiController
{
    [ApiExplorerSettings(IgnoreApi = true)]
    public void MySpecialAction()

All 5 comments

Unfortunately, the current version of Swashbuckle is missing a feature to edit each API Declaration once generated, at which point you could just go remove Operations explicitly. This feature will be supported in the upcoming major release. However I should also note, this release will emit Swagger 2.0 instead of 1.2 and at this point I'm tending toward not supporting both Swagger versions in the next release.

Just though of something ... Swashbuckle adds an adapter for generating Swagger on top of the built-in IAPIExplorer. As it happens, this does come with an attribute to ignore certain actions. If you apply it, IApiExplorer won't include a description for the action and as a result, neither will Swashbuckle.

public class ValuesController : ApiController
{
    [ApiExplorerSettings(IgnoreApi = true)]
    public void MySpecialAction()

I can confirm that this does work. I am actively using this exact method to hid non-public controllers in my API.
Regards,
Aaron Havens
Software Developer
CSI Software
(800) 247-3431 x2 – Technical Support
(713) 942-7779 x281 – Direct
[email protected]:[email protected]
www.csisoftwareusa.comhttp://www.csisoftwareusa.com/

From: domaindrivendev [mailto:[email protected]]
Sent: Thursday, September 25, 2014 11:16 AM
To: domaindrivendev/Swashbuckle
Subject: Re: [Swashbuckle] Exclude controllers from docs without using the Obsolete attribute (#90)

Just though of something ... Swashbuckle adds an adapterfor generating Swagger on top the built-in IAPIExplorer. As it happens, this does come with an attribute to ignore certain actions and if you apply it, IApiExplorer won't include a description for the action and as a result, neither will Swashbuckle.

public class ValuesController : ApiController

{

[ApiExplorerSettings(IgnoreApi = true)]

public void MySpecialAction()

—
Reply to this email directly or view it on GitHubhttps://github.com/domaindrivendev/Swashbuckle/issues/90#issuecomment-56843292.

{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Issue on GitHub","action":{"@type":"ViewAction","url":"https://github.com/domaindrivendev/Swashbuckle/issues/90#issuecomment-56843292","name":"View Issue"}}

This message was scanned by ESVA and is believed to be clean.
Click here to report this message as spam.http://mail.csisoftwareusa.com/cgi-bin/learn-msg.cgi?id=B023129D60.A2D88

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Great! Thank you very much.

If i want to Individual Method in Controller instead of whole Controller Ignore what can I do?

Was this page helpful?
0 / 5 - 0 ratings