Skip to content

Commit

Permalink
Expose suppertedSubmitMethods through config API
Browse files Browse the repository at this point in the history
  • Loading branch information
domaindrivendev committed Apr 14, 2016
1 parent f5f3a18 commit 07a7a24
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 315 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ If you're happy with the basic look and feel but want to make some minor tweaks,
c.SetValidatorUrl("http://localhost/validator");
c.DisableValidator();
c.DocExpansion(DocExpansion.List);
c.SupportedSubmitMethods("GET", "HEAD")
});

#### InjectStylesheet ####
Expand All @@ -406,6 +407,10 @@ By default, swagger-ui will validate specs against swagger.io's online validator

Use this option to control how the Operation listing is displayed. It can be set to "None" (default), "List" (shows operations for each resource), or "Full" (fully expanded: shows operations and their details).

#### SupportedSubmitMethods ####

Specify which HTTP operations will have the 'Try it out!' option. An empty paramter list disables it for all operations.

### Provide your own "index" file ###

As an alternative, you can inject your own version of "index.html" and customize the markup and swagger-ui directly. Use the __CustomAsset__ option to instruct Swashbuckle to return your version instead of the default when a request is made for "index". As with all custom content, the file must be included in your project as an "Embedded Resource", and then the resource's "Logical Name" is passed to the method as shown below. See [Injecting Custom Content](#injecting-custom-content) for step by step instructions.
Expand Down
6 changes: 6 additions & 0 deletions Swashbuckle.Core/Application/SwaggerUiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public SwaggerUiConfig(IEnumerable<string> discoveryPaths, Func<HttpRequestMessa
{ "%(ValidatorUrl)", "" },
{ "%(CustomScripts)", "" },
{ "%(DocExpansion)", "none" },
{ "%(SupportedSubmitMethods)", "get|put|post|delete|options|head|patch" },
{ "%(OAuth2Enabled)", "false" },
{ "%(OAuth2ClientId)", "" },
{ "%(OAuth2ClientSecret)", "" },
Expand Down Expand Up @@ -92,6 +93,11 @@ public void DocExpansion(DocExpansion docExpansion)
_templateParams["%(DocExpansion)"] = docExpansion.ToString().ToLower();
}

public void SupportedSubmitMethods(params string[] methods)
{
_templateParams["%(SupportedSubmitMethods)"] = String.Join("|", methods).ToLower();
}

public void CustomAsset(string path, Assembly resourceAssembly, string resourceName)
{
_pathToAssetMap[path] = new EmbeddedAssetDescriptor(resourceAssembly, resourceName, path == "index");
Expand Down
Loading

0 comments on commit 07a7a24

Please sign in to comment.