Book Image

Mastering ServiceStack

By : Andreas Niedermair
Book Image

Mastering ServiceStack

By: Andreas Niedermair

Overview of this book

Table of Contents (13 chapters)

Querying your service with Swagger

Documenting your API is only one part of making it explorable, you can also offer a way to play with your API by generating requests and display their responses, along with the possibility to read through the documentation.

Therefore, Swagger, which is an advanced testing environment, is available for any ServiceStack service and can be enabled by adding the ServiceStack.Api.Swagger NuGet package to your solution. Additionally, you have to add a SwaggerFeature object to your host's configuration, as shown:

using Funq;
using ServiceStack;

public override void Configure(Container container)
  this.Plugins.Add(new SwaggerFeature());

This will offer a new link in the plugin section of the metadata page available at /metadata, as shown in the following figure:

This link points to /swagger-ui/ in the default configuration. There, you will find the following interface, which also includes documentation on the service and its operations:

We can now populate the...