FAQ¶
OpenAPI 3.0 vs 3.1: which one should I use?¶
Use 3.0.0 if downstream tooling in your stack still expects OpenAPI 3.0.
Use 3.1.0 if your tooling supports it and you want newer JSON Schema alignment.
from azure_functions_openapi import OPENAPI_VERSION_3_1, get_openapi_json
spec = get_openapi_json(openapi_version=OPENAPI_VERSION_3_1)
How do I add authentication to my docs?¶
Use security + security_scheme in @openapi, or pass security_schemes to spec generation.
@openapi(
summary="Protected route",
security=[{"BearerAuth": []}],
security_scheme={
"BearerAuth": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"}
},
)
Can I use this package without Pydantic?¶
Yes. Use raw schema dictionaries with request_body and response.
@openapi(
request_body={"type": "object", "properties": {"name": {"type": "string"}}},
response={200: {"description": "OK"}},
)
How do I customize Swagger UI?¶
Use render_swagger_ui(title=..., openapi_url=..., custom_csp=..., enable_client_logging=...).
return render_swagger_ui(
title="Service Docs",
openapi_url="/api/openapi.json",
enable_client_logging=True,
)
How can I export the spec to a file?¶
Use the CLI:
azure-functions-openapi generate --output openapi.json --format json
azure-functions-openapi generate --output openapi.yaml --format yaml
Or write strings in Python:
How do I validate the generated spec?¶
Use an external validator such as openapi-spec-validator.
Does this integrate with azure-functions-validation?¶
Yes. A common pattern is using the same Pydantic model for:
- runtime validation (
@validate_http) - OpenAPI schema generation (
@openapi)
Can I assign multiple tags?¶
Yes. Pass a list of strings.
Can I define custom operation IDs?¶
Yes. Set operation_id.
The library sanitizes invalid characters automatically and may prefix with op_ if needed.
Why is my endpoint missing in the generated spec?¶
Common causes:
- missing
@openapion that handler - module containing the function was not imported at startup
- route metadata mismatch in the decorator
See Troubleshooting for a full checklist.