ASP.NET Web API Generate all parameters from model - help pages

前端 未结 2 1864
挽巷
挽巷 2021-02-02 10:12

I\'m busy creating a Web API (Inside a asp mvc4 application). I am using the library suggested on the asp.net site for generating documentation (http://www.asp.net/web-api/overv

2条回答
  •  天涯浪人
    2021-02-02 11:14

    josant's answer works great. I did find it was a bit-over zealous however. I found it was reporting simple things like strings as models and reporting them to be a Char array with a length field!

    We only needed this for models, so I added this code to the end of the GetModelDocumentation method:

    if (parameterDescriptor.ParameterName == "value" || parameterDescriptor.ParameterName == "model")
    {
        retDictionary.Add(parameterDescriptor.ParameterName, typeDocs);
    }
    

    Now it only returns parameter details for non-simple types.

提交回复
热议问题