Swaggeratr
Swaggeratr copied to clipboard
Update swagger-ui to 2.0.latest
It looks like there's a new version of swagger-ui. We should update it.
global asax: protected void Application_Start(object sender, EventArgs e) { RouteTable.Routes.Add(new ServiceRoute("v1/rest", new WebServiceHostFactory(), typeof(RESTful))); RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(Swaggerator.Discoverator))); } issue: when i call .../api-docs, i just get
{"apiVersion":"1.0.0.0","swaggerVersion":"1.2","apis":[{"path":"/v1/rest","description":"A RESTful WCF Service"}]}
although when i walk the code, i see that it eventually calls GetServiceDetails whose string api variable is full of the complete swagger.
Why?
Yes, when you request /api-docs, you're just getting a list of the available apis. The expectation is that you will then request the details of each api separately, for instance by fetching /api-docs/v1/rest.
thanks for this great code, and thanks for getting back to me...
yes, i figured that out the hard way by seeing that the GetServiceDetails(string servicePath) takes what's after the Swaggerator virtual service name, i.e. "api-docs" if that was the name of the service route. your note above will help a lot of people that are new to this code.
then...today, i discovered that the FindMethods function actually looks for interfaces:
Type[] interfaces = serviceType.GetInterfaces();
so...that means that legacy wcf services that do not implement a service interface will return no swagger.
so, i was thinking of adding some code that will pull the methods if the interfaces count is 0. what do you think?