Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Auto generation for OpenAPI json file from function app in VS2017

Open melzoghbi opened this issue 6 years ago • 13 comments

Hi,

I am developing Azure Functions in VS2017 5.13 (Preview) and I would like to generate project documentation from the swagger json file which i generated from azure portal. Since visual studio 2017 doesn’t generate the file, so I got the initial file from azure portal and copied over into my project under swagger folder. I want to re-generate this file when the code is updated automatically.

Also, i updated host.json file by enabling swagger but the json file doesn't get updated as i add or change functions.

{
  "swagger": {
    "enabled":  true
  }
}

Is there official walkthrough on how to integrate swagger json file to generate documentations from code in VS 2017?

melzoghbi avatar Jul 17 '17 20:07 melzoghbi

@alexkarcher-msft Could you please comment?

lindydonna avatar Jul 18 '17 18:07 lindydonna

Right now your best bet is to use CI/CD to deploy your function. Then you can update the OpenAPI definition directly in \site\wwwroot.azurefunctions\swagger\swagger.json

The generator is portal only at the moment, so you'll need to go to the portal and generate a new file each time you change your API.

We'd like to add this functionality in the future, so I'll leave this issue open and pending triage.

alexkarcher-msft avatar Jul 18 '17 21:07 alexkarcher-msft

Thanks @alexkarcher-msft! i will keep you posted.

melzoghbi avatar Jul 19 '17 19:07 melzoghbi

I created an azure function to dynamically create a proper Swagger file which sure helps me. http://www.techmikael.com/2017/08/maybe-most-useful-azure-function-ever.html

wobba avatar Aug 27 '17 10:08 wobba

@alexkarcher-msft, by any chance could you go into a bit more detail on how to do that in CI / CD? I'm using CircleCI and the AZ Python CLI 2, and when I run az functionapp deployment source config-zip blah with a zip file containing \site\wwwroot.azurefunctions\swagger\swagger.json my swagger isn't updated. When I manually create it and then click "download app content", it's only at \swagger\swagger.json. Moving my file there and re-deploying using that command ALSO didn't work.

Sorry for kinda hijacking this issue, but I can't find much in the way of any documentation on how to do this in a scripted fashion and this was really it. I founds lots of ways to do it manually :)

321ckatz123 avatar Feb 09 '18 19:02 321ckatz123

@lindydonna Can you give us any progress update on this feature? Thanks

JasonBSteele avatar Feb 16 '18 15:02 JasonBSteele

@alexkarcher-msft Could you give us any update on this feature request? Thanks!

JDSRAO avatar Dec 11 '18 08:12 JDSRAO

Hello. No updates to provide on this feature. We currently recommend using APIM to front your API if you'd like to generate an OpenAPI definition using a GA tool in Azure.

We also have some limited guidance on deploying your OpenAPI definition using CI/CD https://docs.microsoft.com/en-us/azure/azure-functions/functions-api-definition#CICD

alexkarcher-msft avatar Feb 16 '19 01:02 alexkarcher-msft

Hello. No updates to provide on this feature. We currently recommend using APIM to front your API if you'd like to generate an OpenAPI definition using a GA tool in Azure.

@alexkarcher-msft , I took a look at https://azure.microsoft.com/en-us/blog/announcing-the-preview-of-openapi-specification-v3-support-in-azure-api-management/ which has some details on how to import and export a definition, but unless I have missed something that doesn't support generating one?

As far as I know there is currently no way of generating a full OpenAPI definition (i.e. one that includes the schema) from a Function with object binding?

JasonBSteele avatar Feb 16 '19 12:02 JasonBSteele

Take a look at the post https://devkimchi.com/2019/02/02/introducing-swagger-ui-on-azure-functions/ and the code for it at https://github.com/aliencube/AzureFunctions.Extensions which shows good promise for automation.

wobba avatar Feb 16 '19 12:02 wobba

Thanks @wobba ! We're currently using your solution and were contemplating extending it with Attributes - so this will save us a load of work!

JasonBSteele avatar Feb 16 '19 12:02 JasonBSteele

Any updates on this process for APIM / OpenApi synch with Azure Functions? Should this issue be closed / is there a good path in VS 2019 / VSCode for this?

asears avatar Sep 03 '20 19:09 asears

Any update for auto-generation of OpenAPI JSON file from Azure func app as of 2021 now

PingPongSet avatar Apr 22 '22 08:04 PingPongSet