Jusas / NSwag.AzureFunctionsV2

NSwag for Azure Functions
MIT License
20 stars 5 forks source link

Support for non static functions #3

Closed MariuszKogut closed 5 years ago

MariuszKogut commented 5 years ago

Hi there, First of all, thanks for your great project. I'm a big fan of NSwag and want to use it for my Azure Functions Host. In my project, I'm using DI as described here => https://docs.microsoft.com/de-de/azure/azure-functions/functions-dotnet-dependency-injection. So my functions are not static. The generated document is empty, when I use your example swagger endpoint.

{
  "x-generator": "NSwag v13.0.4.0 (NJsonSchema v10.0.21.0 (Newtonsoft.Json v11.0.0.0))",
  "swagger": "2.0",
  "info": {
    "title": "Swagger",
    "version": "1.0.0"
  },
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ]
}

Do you have some plans to support also non static functions?

Thanks, Mariusz

MariuszKogut commented 5 years ago

Took a brief look into your source code. I guess the problem is located here:

Find classes: https://github.com/Jusas/NSwag.AzureFunctionsV2/blob/master/src/NSwag.SwaggerGeneration.AzureFunctionsV2/AzureFunctionsV2ToSwaggerGenerator.cs#L47

Find methods: https://github.com/Jusas/NSwag.AzureFunctionsV2/blob/master/src/NSwag.SwaggerGeneration.AzureFunctionsV2/AzureFunctionsV2ToSwaggerGenerator.cs#L231

What do you think?

Jusas commented 5 years ago

Hi MariuszKogut, you're absolutely correct, I wasn't fully aware that Functions in non-static classes was supported. You've proven me wrong. So, I suppose we can get rid of the static requirement on both the class and the method. Doesn't look like a big deal, I can probably make the changes and run the necessary tests tomorrow and release a new version to Nuget.

Jusas commented 5 years ago

@MariuszKogut A new version (v1.1.1) has been released to NuGet that adds support to non-static Functions. I'm closing this issue, please open another issue if you run into any problems.