Reputation: 6202
I added Swashbuckle
in my Azure Function
v3 to generate Swagger documentation. I followed the instruction in this post and locally is working.
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="
}
]
}
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).
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.
I updated AzureExtensions.Swashbuckle
to the version 3.1.6 and now I have another error on Azure:
Failed to load API definition.
I checked in the project .csproj
and I can see
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
I created a test project on Github.
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.
Upvotes: 0
Views: 3264
Reputation: 56
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.
Now, only fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle supports your version of Azure Functions, (which is v3)
So, you need to use only AzureExtensions.Swashbuckle package,
<PackageReference Include="AzureExtensions.Swashbuckle" Version="3.1.6" />
and configure it as described in repo.
Upvotes: 1
Reputation: 23111
According to my test, when we use sdk AzureFunctions.Extensions.Swashbuckle
to integrate swagger fro Azure function, we can do the following steps to include xml
.csproj
file <PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
{
"version": "2.0",
"extensions": {
"Swashbuckle": {
"XmlPath": "{your document xml file name}"
}
}
}
For more details, please refer to the document
Upvotes: 0