c# - Configure Web API to provide metadata -


i new to.net /mvc/ web api. have created .net web api accepts input parameters queries oracledatabase , returns result in json. pretty following simple c# codes. controller looks like

public class datacontroller : apicontroller {    [httpget]     public httpresponsemessage getdetails(string room, datetime dob_gt)     {             list<oracleparameter> prms = new list<oracleparameter>();             prms.add(new oracleparameter("room", oracledbtype.varchar2, room, parameterdirection.input));             prms.add(new oracleparameter("dob_gt", oracledbtype.date, dob_gt, parameterdirection.input));            string connstr = configurationmanager.connectionstrings["sdatabaseconnection"].connectionstring;             using (oracleconnection dbconn = new oracleconnection(connstr))             {                 dataset userdataset = new dataset();                 var strquery = "select * sample_results_vw room = :room , dob > :dob_gt ";                 var returnobject = new { data = new oracledatatablejsonresponse(connstr, strquery, prms.toarray()) };                 var response = request.createresponse(httpstatuscode.ok, returnobject, mediatypeheadervalue.parse("application/json"));                 contentdispositionheadervalue contentdisposition = null;                 if (contentdispositionheadervalue.tryparse("inline; filename=tgsdata.json", out contentdisposition))                 {                     response.content.headers.contentdisposition = contentdisposition;                 }                 return response;             } 

this works perfectly. client application requesting metadata. can pull in metadata service. not sure if can configure existing api provide metadata. or have smoething scratch

there projects available in form of nuget packages can this. no need write scratch.

you can add swagger provide metadata of api. see https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger , https://github.com/domaindrivendev/swashbuckle

using asp.net web api helppages (https://www.nuget.org/packages/microsoft.aspnet.webapi.helppage/) can add wadl support using https://www.nuget.org/packages/leeksnet.aspnet.webapi.wadl/


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -