I have an Azure Function App using Swashbuckle.
[FunctionName("DoWorkV2")]
[QueryStringParameter("DoWorkParameters", "", DataType = typeof(DoWorkParametersV2), Required = true)]
[ProducesResponseType(typeof(DoWorkResults), (int)HttpStatusCode.OK)]
public static async Task<IActionResult> DoWorkV2(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log, ExecutionContext context)
{
The return type as defined by ProducesResponseType attribute is included in the schema section. The parameter as defined by QueryStringParameter attribute is not included in the schema section.
How do I make the parameter appear in the schema section so my consumers can know what kind of parameter to pass?
I ended up creating dummy method using ProducesResponseType for the type contained in the QueryStringParameter. Now I have two extra methods to do nothing. Seems kind of hacky, but the type now appears in the schema section of Swagger page.
[FunctionName("DoWorkParametersV2Factory")]
[ProducesResponseType(typeof(DoWorkParametersV2), (int)HttpStatusCode.OK)]
public static async Task<IActionResult> DoWorkParametersV2Factory(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log, ExecutionContext context)
{
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.