Reputation: 61
Is there a way that I can, on the method summary XML, list the possible values for a string parameter and document it on Swagger?
Like, on the method below, the possible values for myParam are Y and N, I want to get it to my Swagger documentation.
/// <summary>
/// My method.
/// </summary>
/// <param name="myParam">String parameter with predefined values.</param>
/// <returns>Something.</returns>
[HttpGet]
[ProducesResponseType(typeof(string), 200)]
public JsonResult MyMethod(string myParam)
{
...
}
Upvotes: 1
Views: 2299
Reputation: 31770
Is there a way that I can, on the method summary XML, list the possible values for a string parameter and document it on Swagger?
No you cannot do that
However, swagger defines a description field which supports rich formatting, and which you can use to describe your parameters and therefore the allowed values which may be passed in. This will be visible to anyone consumiong the API definition.
Something like:
paths:
/MyMethod/myParam:
get:
summary: Gets a user by ID.
parameters:
- in: path
name: myParam
type: string
required: true
description: Must be in the form of "X" or "Y"
Upvotes: 2