Skip to content
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

Need to show specific url on swagger UI using configuration #399

Closed
ravi032 opened this issue Jun 17, 2015 · 2 comments
Closed

Need to show specific url on swagger UI using configuration #399

ravi032 opened this issue Jun 17, 2015 · 2 comments

Comments

@ravi032
Copy link

ravi032 commented Jun 17, 2015

I have requirement that I want to show specific URLs on Swagger UI. For example, I want to show only get action methods from all controllers in web api. Could I do that with any configuration in swashbuckle.

@davetransom
Copy link
Contributor

First option: you can control what is included via the ApiExporerSettingsAttribute (see #153 (comment))

[ApiExplorerSettings(IgnoreApi=true)]
public class MyController : ApiController

Otherwise, you should be able to remove the other verbs with a document filter - something along the lines of:

class RemoveVerbsFilter : IDocumentFilter
{
    public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
    {
        foreach (PathItem path in swaggerDoc.paths.Values)
        {
            path.delete = null;
            path.head = null;
            path.options = null;
            path.patch = null;
            path.post = null;
            path.put = null;
        }
    }
}

and in your swagger config:

...EnableSwagger(conf => 
{
    // ...

    conf.DocumentFilter<RemoveVerbsFilter>();
});

There might be other approaches to do it as well.

@domaindrivendev
Copy link
Owner

The approaches above (thanks to @davetransom) should allow you to do this

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

No branches or pull requests

3 participants