API documentation(Swagger UI ) for Python Azure function
Asked Answered
G

4

10

We have built APIs based on Azure function and all of the APIs are python based. I know that APIM provides a nice way of importing Azure function and creating and managing APIs. However, i am looking for a light & quick solution for developers so they can work among themselves.

Swagger is very popular in Java ecosystem and we are using in our spring boot application by just adding a few annotations.

Is there anything similar available for Azure functions written in Python. My end goal to have API documentation exposed by some endpoints so that different teams (API producers & consumers) can work efficiently without going through the confluence, etc

Gyre answered 27/1, 2021 at 8:38 Comment(0)
R
3

This is certainly possible for a C# Azure Functions app quite easily via this official extension https://github.com/Azure/azure-functions-openapi-extension

I don't think the same can be said for the Python at this time, unfortunately.

Rusk answered 17/9, 2021 at 10:44 Comment(0)
L
2

It is fairly simple with Azure. Since, these are functions, using swagger does not make sense and I guess it won't be possible too.

Azure has a built-in open API definition service. All you need to do is create a API Management Instance and them import the functions into it. After importing all the functions, you can go ahead and download the OpenAPI definition file. You can even choose to host it somewhere for easy access.

Here is the link to a detailed guide

Linoel answered 7/6, 2021 at 12:8 Comment(1)
I will try to expose my python function app to custom GPT that requires open API. I will come back with results of GPTs - Azure function app integration.Sandrasandro
D
0

I'm not certain if you can do it, but the company I work for has SwaggerHub, which allows me to generate server stubs in a number of languages including python-flask. I tried this on one of our APIs and checked the code - it's using a framework called Connexion - see here and here.

Connexion is a framework on top of Flask that automagically handles HTTP requests defined using OpenAPI

Another thing to note; looks like you can use flask framework for Azure function app as per here.

Dominick answered 4/6, 2021 at 11:51 Comment(0)
T
0

NOT POSSIBLE FOR NOW

It's still on the roadmap, not possible for now. The workaround is to wrap your function through API Management service (not a cheap service).

[Further Reading]

ATTEMPT LOCALLY WITH FASTAPI BASED AZURE FUNCTION (or other supported framework)

Although I've not tried I wonder if you can do something with a FastAPI based Azure Function for instance. I don't think so, because the Swagger endpoint is different from your service endpoint and thus it would probably be unavailable. But you can try it and see if you have access. Maybe you can make the OpenAPI work locally which would be of great help.

Team answered 16/1 at 15:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.