Documenting ServiceStack web services [closed]

2019-04-29 20:53发布

问题:

What are the options for documenting a ServiceStack bases web services and I'm not talking about a one line string.

I would like to be able to document, in detail (which can be long), return types, possible HTTP responses, add detailed examples etc.

Is there any support for this in ServiceStack (I couldn't find it)? If not has anybody solved the problem in some other way.

回答1:

You can provide metadata descriptions for each of your web services by attributing your Request DTOs with [Api] and [ApiMember] attributes. This information will be displayed on the dynamic metadata pages.

Another option is to simply create your own dynamic html page, which ServiceStack allows you to do by simply returning a string (containing your html markup). If you go this route you can access the Service Types metadata with the global EndpointHost.ServiceOperations property.

Also if dynamically generating html with C# is not your preference you can also generate html using the built-in Razor Markdown format which makes generating html quite pleasant :)



回答2:

I realize this question is a couple years old, but there is now Swagger support for ServiceStack API's @ https://github.com/ServiceStack/ServiceStack/wiki/Swagger-API