Swashbuckle for Azure Functions:在Azure上运行时未提供API定义 [英] Swashbuckle for Azure Functions: No API definition provided when it runs on Azure

查看:111
本文介绍了Swashbuckle for Azure Functions:在Azure上运行时未提供API定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure Function v3中添加了Swashbuckle以生成Swagger文档.我按照此帖子中的说明进行操作并且在本地正常工作.

I added Swashbuckle in my Azure Function v3 to generate Swagger documentation. I followed the instruction in this post and locally is working.

我从笔记本电脑中将此功能发布到了我的功能中的Azure门户.该功能正在运行,但是没有Swagger文档.

I published from my laptop this function to the Azure Portal in my function. The function is working but there is not Swagger documentation.

{
  "schemaValidationMessages": [
    {
      "level": "error",
      "message": "Can't read from file https://azuks-myfnz-q001.azurewebsites.net/api/swagger/json?code="
    }
  ]
}

我签入了项目以验证XML的生成.我可以在项目中看到XML.另外,我尝试更改文件属性复制到输出目录"(显然不是必需的).

I checked in the project to verify the generation of the XML. I can see the XML in the project. Also, I tried to change the file property "Copy to Output Directory" (apparently it is not required).

我在 Debug Release 中多次发布了Azure函数,并且只有一次在Debug模式下工作.我试图以相同的结果删除现有文件.

I published the Azure Function multiple times in Debug or Release and only once was working in Debug mode. I tried to Delete Existing Files with the same result.

我已将AzureExtensions.Swashbuckle更新到版本3.1.6,现在在Azure上还有另一个错误:

I updated AzureExtensions.Swashbuckle to the version 3.1.6 and now I have another error on Azure:

无法加载API定义.

Failed to load API definition.

我签入了项目.csproj,我可以看到

I checked in the project .csproj and I can see

<PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

我在 Github 上创建了一个测试项目.

I created a test project on Github.

出于相同的原因,jsonUI的代码参数不能相同.如果您使用获取函数网址打开Swagger网址并从UI函数复制该网址,则该网址就可以使用.

For same reason, the code param can't be the same for json and UI. If you open your Swagger url with Get Function url and copy the url from UI function, it is working.

推荐答案

1.4.4是同一个lib的较旧版本,该版本是3.1.6的分支版本.

1.4.4, that is referenced by your project is an older version of the same lib, which is forked and has version 3.1.6.

由于不再支持原始存储库.

As original repo is no longer supported.

现在,只有叉子=> https://github.com/vitalybibikov/azure功能扩展swashbuckle 支持您的Azure Functions版本(v3)

Now, only fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle supports your version of Azure Functions, (which is v3)

因此,您只需要使用AzureExtensions.Swashbuckle程序包

So, you need to use only AzureExtensions.Swashbuckle package,

   <PackageReference Include="AzureExtensions.Swashbuckle" Version="3.1.6" />

并按照存储库中的说明进行配置.

and configure it as described in repo.

这篇关于Swashbuckle for Azure Functions:在Azure上运行时未提供API定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆