How to ignore parameters in asp.net web api help page which are generated automatically from routing and from action

1.1k views Asked by At

One of my action parameters is instance of class which have param1, param2, param3 parameters (with [FromUri] attribute and I can't replace it with [FromBody])
And that parameters are in routing too.

When asp.net web api help page generates parameters from action I am getting duplicates of them in URI parameters.
How can I ignore one of them?

1

There are 1 answers

0
Arne On

In Areas\HelpPage\HelpPageConfigurationExtensions.cs find the method GenerateUriParameters and comment out the else clause.

else
{
    Debug.Assert(parameterDescriptor == null);

    // If parameterDescriptor is null, this is an undeclared route parameter which only occurs
    // when source is FromUri. Ignored in request model and among resource parameters but listed
    // as a simple string here.
    ModelDescription modelDescription = modelGenerator.GetOrCreateModelDescription(typeof(string));
    AddParameterDescription(apiModel, apiParameter, modelDescription);
}

Note that this might remove too many parameters from your help pages if you don't consistently use [FromUri]