azure-functions-extensions-swashbuckle icon indicating copy to clipboard operation
azure-functions-extensions-swashbuckle copied to clipboard

Does not work with Functions v3

Open kjartanvalur opened this issue 6 years ago • 62 comments

I get the following error.

A host error has occurred during startup operation 'a9f43d8a-89ae-4480-8c8f-9b6b8ad75098'. [5.12.2019 14:46:13] AzureFunctions.Extensions.Swashbuckle: Could not load type 'Microsoft.AspNetCore.Mvc.Internal.DefaultValidationMetadataProvider' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

kjartanvalur avatar Dec 05 '19 14:12 kjartanvalur

Same here!

TiagoCastilhos avatar Dec 12 '19 19:12 TiagoCastilhos

the same issue(((

vvboxplosive avatar Dec 13 '19 10:12 vvboxplosive

ummmm. very difficult.

yuka1984 avatar Dec 14 '19 07:12 yuka1984

@yuka1984 do you know what the underlying problem is? Maybe we can help

LockTar avatar Dec 14 '19 08:12 LockTar

@LockTar An error occurred because the namespace of DefaultValidationMetadataProvider changed. I am trying to solve it by preparing my own DefaultValidationMetadataProvider. But, this method is not clean. Do you have any other good ideas?

yuka1984 avatar Dec 14 '19 08:12 yuka1984

@yuka1984 I have already try your new privew 1.4.5 version. But I got a new error: {"Could not load type 'Swashbuckle.AspNetCore.Swagger.SwaggerDocument' from assembly 'Swashbuckle.AspNetCore.Swagger, Version=5.0.0.0, Culture=neutral, PublicKeyToken=62657d7474907593'.":"Swashbuckle.AspNetCore.Swagger.SwaggerDocument"}

vvboxplosive avatar Dec 16 '19 09:12 vvboxplosive

As I understand, we need to update Swashbuckle.AspNetCore to -Version 5.0.0-rc5.

vvboxplosive avatar Dec 16 '19 10:12 vvboxplosive

@yuka1984 What is the status on this?

kjartanvalur avatar Dec 18 '19 08:12 kjartanvalur

@vvboxplosive @kjartanvalur I'm sorry. My fix was not valid. It seems difficult to create a library of the same version corresponding to Function v2 and v3. I am planning to update the version of this package to 3.0 to support FunctionsV3. This package will not support FunctionsV2.

yuka1984 avatar Dec 18 '19 10:12 yuka1984

@yuka1984 Thanks for the info

kjartanvalur avatar Dec 18 '19 13:12 kjartanvalur

Good morning! You could release a version "2.0" for the package to work with functions v2, without changes in the package. Then you could release the version "3.0" to work with functions v3. I think it would be good because it's more intuitive for us (users in general). I tried to figure out the problem to give a possible solution, but unfortunately I didn't have much time...

TiagoCastilhos avatar Dec 18 '19 13:12 TiagoCastilhos

Fixed it in the fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle As I needed Nuget asap. (AzureExtensions.Swashbuckle) Can merge it later here if required

vitalybibikov avatar Dec 28 '19 16:12 vitalybibikov

Fixed it in the fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle As I needed Nuget asap. (AzureExtensions.Swashbuckle) Can merge it later here if required

I did that and It works well, but now the RequestBodyType is not working, do you know any workaround that?

Francisjbq avatar Jan 15 '20 16:01 Francisjbq

Any progress on this issue?

Mrkisha avatar Jan 20 '20 09:01 Mrkisha

@yuka1984 any updates?

iTKerry avatar Jan 22 '20 16:01 iTKerry

@yuka1984 Any updates on this issue for Azure Functions v3?

RorroRojas3 avatar Jan 28 '20 01:01 RorroRojas3

Bump, any updates ?

BlowaXD avatar Feb 20 '20 09:02 BlowaXD

So I did some research, the issue is caused by a missing ModelMetadata in the ApiParameterDescription. I made a fork of the fix from vitalybibikov and added this object.

@yuka1984 A working version is in https://github.com/mligtenberg/azure-functions-extensions-swashbuckle Please feel free to merge it back.

mligtenberg avatar Feb 20 '20 11:02 mligtenberg

@mligtenberg @yuka1984 is it possible to merge it to the NuGet package?

So I did some research, the issue is caused by a missing ModelMetadata in the ApiParameterDescription. I made a fork of the fix from vitalybibikov and added this object.

@yuka1984 A working version is in https://github.com/mligtenberg/azure-functions-extensions-swashbuckle Please feel free to merge it back.

@mligtenberg Thank you very much, everything seems to be working perfectly. @yuka1984, is it possible to merge it to master and incorporate it to the NuGet package?

RorroRojas3 avatar Feb 21 '20 23:02 RorroRojas3

Fixed it in the fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle As I needed Nuget asap. (AzureExtensions.Swashbuckle) Can merge it later here if required

I did that and It works well, but now the RequestBodyType is not working, do you know any workaround that?

Same issue for me, I opened a new Issue #30 to over it.

I opened a new issue because the solution here did work for me, but now I have an issue with RequestBody.

Thanks all

jeffward01 avatar Feb 24 '20 16:02 jeffward01

Fixed it in the fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle As I needed Nuget asap. (AzureExtensions.Swashbuckle) Can merge it later here if required

I did that and It works well, but now the RequestBodyType is not working, do you know any workaround that?

Same issue for me, I opened a new Issue #30 to over it.

I opened a new issue because the solution here did work for me, but now I have an issue with RequestBody.

Thanks all

Did you try my fork? I haven't published it to NuGet yet. But there is a fix in there for the request body issue

mligtenberg avatar Feb 24 '20 16:02 mligtenberg

Fixed it in the fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle As I needed Nuget asap. (AzureExtensions.Swashbuckle) Can merge it later here if required

I did that and It works well, but now the RequestBodyType is not working, do you know any workaround that?

Same issue for me, I opened a new Issue #30 to over it. I opened a new issue because the solution here did work for me, but now I have an issue with RequestBody. Thanks all

Did you try my fork? I haven't published it to NuGet yet. But there is a fix in there for the request body issue

I hope you can make a new published in Nuget soon, I tested your changes last week and all work good, I am excited to include them in my solution!

Francisjbq avatar Feb 24 '20 16:02 Francisjbq

I made a package available on NuGet called AzureFunctions.Swashbuckle for those who need a fix now. It contains the fixes of vitalybibikov and my own fixes

mligtenberg avatar Feb 24 '20 18:02 mligtenberg

@mligtenberg Thanks you! Merged your changes and updated.

vitalybibikov avatar Feb 24 '20 19:02 vitalybibikov

The only thing that I had changed and published in NuGet is SupportedRequestFormat attribute fix.

As far as I can see, your solution requires code changes, with addition of

[SupportedRequestFormat("application/json")]

above every single function.

Due to the fact, that in MVC, "application/json" media type was a default supported one. I've made it the same way => so if you do not have the attribute specified => "application/json" is set by default.

Thus no code changes, except for update is required.

Sorry for the wait, here is the NuGet: https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle/releases/tag/3.0.0

vitalybibikov avatar Feb 24 '20 21:02 vitalybibikov

Perfect, I'm unlisting my temporary package as we speak.

mligtenberg avatar Feb 24 '20 21:02 mligtenberg

I have spotted an issue in the new nuget package. I am not sure if this is already in the original library, but parameters in the url definition should exactly match the parameter in the body. Otherwise it won't show up in the parameters. {id:minlength(10)} doesn't work for example

mligtenberg avatar Mar 03 '20 14:03 mligtenberg

@mligtenberg @vitalybibikov What package should I be using to make this work with v3 and .net core 3.1? The versions on nuget are 3 months old, yet said things are published?

This is the error when I use the v3 of the package or the 1.4.5 preview.

3/3/2020 5:15:10 PM] The 'Swagger' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Swagger'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the bin ding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

bbakermmc avatar Mar 03 '20 17:03 bbakermmc

@bbakermmc You should use https://www.nuget.org/packages/AzureExtensions.Swashbuckle/ package at the moment.

Created from this fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle

You might also want to add

builder.AddSwashBuckle(Assembly.GetExecutingAssembly());

if you haven't

vitalybibikov avatar Mar 03 '20 17:03 vitalybibikov

@vitalybibikov Yeah I have a startup class thats that same as your sample and still have the error.

I must have some bad references or something, added it to another project and seems to be working on that one.

bbakermmc avatar Mar 03 '20 17:03 bbakermmc