3

I need to dynamically generate the help for some WEB-API. The problem is that are dynamic both in the input parameters that in the structure of output.

See the Example:

[HttpGet]
[Route("API/Individuals")]
[ActionName("Individuals")]
public HttpResponseMessage Select()
{
     var Params = this.Request.RequestUri.ParseQueryString();
     string UserNameCVT = Code.RemappingUser.Remap(UserName.Name);
     DataSet ds = Models.Individuals.Individuals.SelectDS(UserNameCVT, Params);
     List<Dictionary<string, object>> lDict = DecodeIndividualsFromDS(ds);

     response = Request.CreateResponse(HttpStatusCode.OK, lDict);
     return response;
}

By doing this, the API is to decouple that from FE DB below, leaving them free to modify the data structures according to their needs.

Is it possible to generate a complete Help once the structures are defined (without changing the code of the API)?

1 Answer 1

1

Yes, you can. The key line of code in the XML documentation provider is this (from this getting started page):

config.SetDocumentationProvider(new XmlDocumentationProvider(
HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

As you see, the documentation is read from a file path. If you can dynamically create that file on the start of your application, and then pass in the file path, you are set. (You have to find a way to handle those end points dynamically, but that is not in the scope of this question)

Also, if you need to do more, you can create a custom implementation by taking the XmlDocumentationProvider from Github and write your own.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. My problem now is how to dynamically create the documentation files. I saw that there are different attributes, but I can not find good documentation/examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.