c# - Automatically provide sample data responses in a WebAPI scaffolding? -
in team environments common 1 person consuming api while implementing api. commonly doing architecture work front specify request , response contracts each endpoint. there easy way give endpoint binding , automatically generate sample output data match response contract save implementing mock each endpoint manually?
example:
[actionname("getuserdetails")] [httppost] public httpresponsemessage getuserdetails(getuserdetailsrequest request) { // take a: // var response = new userdetailsresponse { // someproperty = "somevalue", ... // } request.createresponse(response); }
while i'm looking be:
[actionname("getuserdetails")] [httppost] public httpresponsemessage getuserdetails(getuserdetailsrequest request) { request.createresponse(generatesamplepayload<userdetailsresponse>()); }
it sounds silly request, when architect feeding team of dozen or more apis being consumed weeks if not months out being implemented , these mock implementations become pivotal. looking see if there anyway save time doing rather putting own dummy data in every response out.
i know use reflection , have pre-defined text or numbers , pattern matching on variable names through reflection give sense of sane responses, wondering if had simpler way go doing this?
Comments
Post a Comment