Reputation: 4202
Using Swagger-UI and ServiceStack, I'm trying to use the Api
attribute to name my services a little cleaner.
I am having a hard time figuring out where the attribute needs to be for it to add a description
property to the api in the resources
endpoint created by swagger.
I have a base request that is inherited by a few other requests for my customer end points. The Api
attribute works only when placed on this particular request dto. If I move it to another, it stops working. Here is an exmaple of what my swagger page looks like:
Here is the code for that:
And here is the code that doesn't seem to work:
I'd like to have a friendly name for each service. Thanks!
Edit: I did track down some code in the ServiceStack codebase that indicates it is looking for the FirstAttribute
. I tried testing by changing the order of things and didn't get the desired results either. I was looking at AttributeExtensions.cs if that helps.
Upvotes: 3
Views: 133
Reputation: 143399
You can use [Api("API Description")]
or [Description("API Description")]
to add a Description to a single Service although this doesn't always map directly to a Swagger Route Description as the Swagger UI groups multiple routes under a single top-level route which covers multiple different services sharing the top-level route.
But you can specify a Route Summary with the RouteSummary
dictionary on SwaggerFeature
, e.g:
Plugins.Add(new SwaggerFeature {
RouteSummary = {
{ "/top-level-path", "Route Summary" }
}
});
Upvotes: 1