URI Parameters section on action help page is intended for description of action parameters that are bind from the URI query string (e.g. ...?SomeParam=SomeValue
). In your case version
is just a part of URI path that is not related to action parameters. So having it described in URI Parameters section could be confusing. That's why I propose to remove it from this section and (if required) put description for version
template to some other section of help page.
To achieve this you should:
Remove version
from URI Parameters list.
This step is not trivial because version
from route template is recognized by ApiExplorer
as action parameter. Suppressing it will require modification of generated code that fills a model for API help page (HelpPageApiModel
). This code resides in HelpPageConfigurationExtensions.GenerateUriParameters()
method. Find the following lines:
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);
and add condition for version
parameter:
Debug.Assert(parameterDescriptor == null);
if (apiParameter.Documentation == null && String.Equals(apiParameter.Name, "version", StringComparison.InvariantCulture))
{
continue;
}
// 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);
Now you'll get the following help page:

Add specific section for version URI template:
Open view file Areas\HelpPage\Views\Help\DisplayTemplates\HelpPageApiModel.cshtml
and add version section that you want. For example:
...
<h2>Request Information</h2>
<h3>Version info</h3>
Put some info about version here.
<h3>URI Parameters</h3>
@Html.DisplayFor(m => m.UriParameters, "Parameters")
...
Such view will give you:

If however you want to see version description in URI Parameters section, you could return to HelpPageConfigurationExtensions.GenerateUriParameters()
method and replace above code with the following:
Debug.Assert(parameterDescriptor == null);
if (apiParameter.Documentation == null && String.Equals(apiParameter.Name, "version", StringComparison.InvariantCulture))
{
apiParameter.Documentation = "Put description for version parameter here.";
}
// 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);
This will give you:

Well, these approaches are not perfect (I'm not a fan of modifying generated HelpPageConfigurationExtensions
). But seems like there is no other way to suppress or fill description for version
parameter.