Tuesday, 15 February 2011

c# - Extending ApiExplorer using XML Documentation -



c# - Extending ApiExplorer using XML Documentation -

i've plugged asp.net web api help page 1 of our projects, i'm wanting extend range of info that's beingness read xml documentation file.

specifically, of our endpoints homecoming resources that, in add-on resource's info include number of <link> elements, have rel , uri properties, link other resources , endpoints. we've extended xml documentation include documentation on rels may included in each resource:

/// <summary> /// retrieves x resource /// </summary> /// <returns>an x</returns> /// <resources> /// <resource rel="self">self reference</resource> /// <resource rel="related-item1">description of related item 1</resource> /// </resources>

great, goes xml documentation file. however, idocumentationprovider has 2 methods defined on - 1 homecoming "documentation" method (as string), , 1 homecoming documentation parameter (ditto). , it's implementation of interface that's searching through xml documentation.

i could seek stuffing xml info documentation string, alongside actual documentation, feels ugly. i'd extend interface new method retrieve more structured info , utilize populate suitably extended helppageapimodel. i'm not sure how best go this.

any suggestions?

in installed file @ areas\helppage\helppageconfigurationextension.cs, there next method grab action descriptor of action , customize documentation need , populate 'extended' helppageapimodel , might know need modify helppageapimodel.cshtml take 'extended' helppageapimodel properties if any.

private static helppageapimodel generateapimodel(apidescription apidescription, helppagesamplegenerator samplegenerator)

doing customizations in method improve because helppageapimodel cached after first call. so, if customizations in above method, automatically gain caching experience.

adding method on idocumentationprovider isn't going help in end needing phone call somehow web api framework wouldn't have knowledge of it.

example of how hold of action , parameters below:

private static helppageapimodel generateapimodel(apidescription apidescription, helppagesamplegenerator samplegenerator) { helppageapimodel apimodel = new helppageapimodel(); apimodel.apidescription = apidescription; httpactiondescriptor currentactiondescriptor = apidescription.actiondescriptor; ienumerable<httpparameterdescriptor> currentactionparamdescriptors = ad.getparameters();

btw, there bug 'return' documentation of action not shown in help page, prepare doing customizations. yao has blogs on help page on here.

c# xml asp.net-mvc asp.net-web-api

No comments:

Post a Comment