[英]How to display post body example by default in swagger UI from azure functions(2.0)
I'm new to swagger open API documentation.我是 swagger 打开 API 文档的新手。 Integrating the Aliencube.AzureFunctions.Extensions.OpenApi.Core in azure function app 2.0 .
在azure function 应用程序 2.0中集成Aliencube.AzureFunctions.Extensions.OpenApi.Core 。
Here is the code:这是代码:
[FunctionName("TestFunction")]
[OpenApiOperation(operationId: "TestFunction", tags: new[] { "TestFunction" })]
[OpenApiRequestBody("text/plain", typeof(string))]
public static async Task<IActionResult> TestFunctionRun([HttpTrigger(AuthorizationLevel.Anonymous,"post", Route = null)] HttpRequest TestFunctionRequest, ExecutionContext executionContext)
{
{
//definition of function
}
}
In Swagger it is displaying as below在Swagger中显示如下
we are expected to display below example value by default我们应该默认显示下面的示例值
{
"username" : "testuser",
"userid" : "1"
}
If the above Expected example value is displayed by default by using AzureFunctions.Extensions.Swashbuckle in azurefunction 2.0.如果使用azurefunction 2.0 中的 AzureFunctions.Extensions.Swashbuckle 默认显示上述 Expected 示例值。 It is also help full for us.
这对我们也很有帮助。
Please help me out from this problem as we are running out of time.请帮我解决这个问题,因为我们时间不多了。
Thanks in advance!提前致谢!
You should use, Pet
is a model.你应该使用,
Pet
是一个 model。
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")]
Source code : AzureFunctions.Extensions源码: AzureFunctions.Extensions
Blog : Introducing Swagger UI on Azure Functions博客: 在 Azure 功能上介绍 Swagger UI
set startup project.设置启动项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.