[英]In Swagger UI, how to customize body input ui (model schema UI)
[英]How to display post body example by default in swagger UI from azure functions(2.0)
我是 swagger 打開 API 文檔的新手。 在azure function 應用程序 2.0中集成Aliencube.AzureFunctions.Extensions.OpenApi.Core 。
這是代碼:
[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
}
}
在Swagger中顯示如下
我們應該默認顯示下面的示例值
{
"username" : "testuser",
"userid" : "1"
}
如果使用azurefunction 2.0 中的 AzureFunctions.Extensions.Swashbuckle 默認顯示上述 Expected 示例值。 這對我們也很有幫助。
請幫我解決這個問題,因為我們時間不多了。
提前致謝!
你應該使用, Pet
是一個 model。
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")]
設置啟動項目。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.