简体   繁体   中英

How would I add Swagger to my Azure cloud service worker role

I have an Azure cloud service (worker role) running. This worker role exposes a web endpoint using a WebHttpBinding binding. It exposes several REST endpoints using WebInvoke.

Example:

[OperationContract]
[WebInvoke(UriTemplate = "/Test",
    Method = "GET",
    RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json)]
bool Test();

Where or how would I need to start to add a Swagger UI to my project, so external developers can see the documentation on my API?

Any help appreciated. I'm using .NET 4.5.2 and C#

There are currently two Nuget packages -

the Core library (Swashbuckle.Core) and a convenience package (Swashbuckle) that provides automatic bootstrapping.

The latter is only applicable to regular IIS hosted WepApi's. For all other hosting environments, you should only install the Core library and then follow the instructions below to manually enable the Swagger routes.

Once installed and enabled, you should be able to browse the following Swagger docs and UI endpoints respectively:

"your-root-url"/swagger/docs/v1

"your-root-url"/swagger

Here is the github page for your complete reference of this project: https://github.com/domaindrivendev/Swashbuckle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM