trx trx - 16 days ago 5
ASP.NET (C#) Question

Using Swagger in Web API to provide metadata

I have created the Web API which accepts input parameter and returns the JSON result. Since we are not able to use the Web API in adding the web reference
enter image description here
I tried to install the Swagger UL for .Net and Swashbuckle-Swagger for WebAPI from the Nugget Package.Now when try to debug the application

http://localhost:24417/
it throws error saying

Method 'GetDocumentation' in type 'Swagger.Net.XmlCommentDocumentationProvider' from assembly 'Swagger.Net, Version=0.5.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Line 38: throw new Exception("Please enable \"XML documentation file\" in project properties with default (bin\\TGSSampleData.XML) value or edit value in App_Start\\SwaggerNet.cs");


I tried to enable
enter image description here
But still throws the same error. Also can anyone please tell how will we be calling the endpoint from the browser. Earlier before swagger I use to call like
http://localhost:46151/api/TGSData?ROOM=KOMP2&DOB_GT=01-05&DOB_LT=30-DEC-06&STATUS_TYPE=CMPLT
and it will return the JSON result. Please help me with this

Answer

I think this is self explanatory from the throw message Please enable \"XML documentation file\" in project properties with default (bin\TGSanokeData.XNK) value or edit value in App_Start\Swaggernet.cs");

You can do change in in the XML file or or call GlobalConfiguration.Configuration.EnableSwagger and GlobalConfiguration.Configuration.EnableSwaggerUIto set proper values. These are not related to swagger. These are configuration settings related issues.

Comments