Search code examples
swaggerswagger-uiswagger-2.0swagger-editornswag

Swagger to generate definition for custom Restful API (C#.NET)


I'm trying to use swagger for my RESTful api (.net and c#). It's a custom restful api (not ASP.NET Web API nor a web application).

public interface IEmployee
{
    [CustomSecurity(Session.Required)]
    EmployeeResponse GetEmployee(EmployeeRequest request);  
}

I'm using NSwag (https://github.com/NSwag/NSwag) which has NSwagStudio to generate the specs but no success as it does not spec out the method. Is there a way to do it any other way? How do I make swagger understand my custom attribute on the operation?


Solution

  • By default only web api classes are supported, but maybe you can write your own cmd line tool with the generator and your interface as generic parameter (but with web api rules): https://github.com/NSwag/NSwag/wiki/WebApiToSwaggerGenerator