Jon Kennerly - 197 - Dec 10, 2014

Any possibility of overriding the default path of “http://root/swagger-ui” in the SwaggerFeature? I currently have my swagger files at the root of the api.

Promote this variable to a class level property:

            var swaggerUrl = UseBootstrapTheme
                ? “swagger-ui-bootstrap/”
                : “swagger-ui/”;

            appHost.GetPlugin<MetadataFeature>()
                .AddPluginLink(swaggerUrl, “Swagger UI”);

The path needs to be /swagger-ui to match the embedded resource files. If you have Swagger files it should automatically pick up those instead.

If you just wanted to change the link (i.e. not link to SwaggerFeature) you can modify:

appHost.GetPlugin<MetadataFeature>().PluginLinks Dictionary

Jon Kennerly:

That works. As a productionalized product, I want to remove as much as I can about the underlying implementations, such as verbiage with the word “Swagger”.

Took me a while to figure out it has to be done after AppHost.Init().

appHost.GetPlugin<MetadataFeature>().PluginLinks.Remove(“swagger-ui/”); appHost.GetPlugin<MetadataFeature>().PluginLinks.Add(“index.html”, “API Service Browser”);

I do wish this was a property of the SwaggerFeature.
Or a MetaDataFeature.RemovePluginLink(…) to go with the AddPluginLink(…) would also be cleaner.

Thanks again.

Another solution would be to just use a customized copy of the Swagger API from: https://github.com/ServiceStack/ServiceStack/tree/master/src/ServiceStack.Api.Swagger

Yeah plugins registrations run after Configure(), some info about Plugin Lifecycle at: https://github.com/ServiceStack/ServiceStack/wiki/Plugins

In your AppHost you can override OnAfterInit() or register a callback in AppHost.AfterInitCallbacks.

New Remove Plugin API’s added in: https://github.com/ServiceStack/ServiceStack/commit/9002d4827c43dd91e02b298a3b5a56e6e376963a

Although you can always add an equivalent API for stuff like this with an extension method.

Jon Kennerly:

good info. Thanks again.