Skip to main content

Prauga FlexDoc Python adapter

prauga-flexdoc 0.7.3 packages one framework-neutral Python host plus ASGI and WSGI transports. The wheel is self-contained, includes the canonical renderer assets, and keeps FastAPI, Flask, and Django optional.

FastAPI / ASGI

from fastapi import FastAPI
from prauga_flexdoc import setup_fastapi_flexdoc

app = FastAPI(docs_url=None, redoc_url=None)
setup_fastapi_flexdoc(app, '/docs', title='My API')

FastAPI can opt into FlexDoc 3.0 Runtime Intelligence:

setup_fastapi_flexdoc(
    app,
    '/docs',
    title='My API',
    runtime_intelligence=True,
)

When enabled, the helper inspects the live FastAPI/Starlette route tree and serves a no-store snapshot from /docs/__flexdoc/runtime. It compares runtime route presence with app.openapi(), reports Python/FastAPI runtime metadata and request-derived server origin, normalizes Starlette path converters, and marks opaque mounts partial rather than inventing routes. Runtime Intelligence is FastAPI-only in this adapter release; generic ASGI, Flask, Django, and WSGI hosts do not advertise it yet.

Runtime snapshots may reveal endpoints intentionally omitted from OpenAPI. The Python adapter currently relies on application middleware or upstream access control rather than a FlexDoc-native docs-auth option, so protect the FlexDoc docs subtree before enabling Runtime Intelligence on non-private documentation.

Native API-host execution (3.3)

FastAPI can also opt into the existing FlexDoc host-execution protocol:

setup_fastapi_flexdoc(
    app,
    '/docs',
    title='My API',
    try_it_host_execution=True,
    try_it_host_execution_allowed_origins=[
        'https://api.example.internal',
    ],
)

When enabled, the ASGI transport owns POST /docs/__flexdoc/execute and the renderer advertises hostExecution.available: true. The allowlist is server-side and accepts exact HTTP(S) origins only; paths, queries, credentials, and wildcards are rejected. The execute route requires X-FlexDoc-Execute: 1, strips unsafe browser-controlled transport headers, revalidates same-origin redirects, blocks link-local/cloud-metadata targets and dangerous DNS answers, bounds request/response sizes, and consumes the same JSON/multipart envelope used by the Node host and FlexDoc Runner.

This first Python slice intentionally advertises an empty host-only capability list. Basic, Bearer, OAuth2 bearer-token, and header/query API-key request auth are supported because they are part of the canonical request draft; session cookie jars, client certificates, Digest, Hawk, NTLM/Negotiate, OAuth 1.0, and AWS Signature V4 remain unavailable until implemented natively.

For every outbound request and redirect hop, the Python standard-library transport resolves the original hostname, rejects link-local/cloud-metadata answers, and then connects only to that validated address set. The request still retains the original hostname for the HTTP Host header and, for HTTPS, TLS SNI and certificate verification. The executor uses http.client directly and does not route through environment/system HTTP proxies. DNS lookup itself uses the platform's synchronous resolver; the execution deadline is checked immediately after resolution and applies to connection, response headers, and the complete response body, but Python cannot forcibly interrupt a resolver call that is already blocked inside the operating system. Keep exact-origin allowlists narrow and use network egress policy as an additional defense in depth where appropriate.

Flask, Django URL-pattern, and generic WSGI helpers continue to advertise no native execute route in this slice.

For a generic ASGI host that owns its execution policy explicitly:

from prauga_flexdoc import FlexDocASGI, FlexDocConfig, FlexDocHostExecution

executor = FlexDocHostExecution(['https://api.example.internal'])
docs = FlexDocASGI(
    FlexDocConfig(
        path='/docs',
        spec_url='/openapi.json',
        title='My API',
        try_it_host_execution=True,
    ),
    host_execution=executor,
)
app.mount('/docs', docs)

For a generic ASGI host without native execution:

from prauga_flexdoc import FlexDocASGI, FlexDocConfig

app.mount('/docs', FlexDocASGI(
    FlexDocConfig(path='/docs', spec_url='/openapi.json', title='My API')
))

FlexDocConfig and the FastAPI/Flask/Django helpers also accept expand, try_it_default_server, try_it_credentials, and try_it_api_client_persistence_key; the persistence key may be a string or False, and unset values are omitted from renderer options.

Flask / WSGI

from flask import Flask
from prauga_flexdoc import setup_flask_flexdoc

app = Flask(__name__)
setup_flask_flexdoc(app, '/docs', spec_url='/openapi.json', title='My API')

For another WSGI server or framework, use FlexDocWSGI(FlexDocConfig(...)) directly.

Django

from django.urls import path
from prauga_flexdoc import django_urlpatterns

urlpatterns = [
    # your API/OpenAPI routes
    *django_urlpatterns('/docs', spec_url='/openapi.json', title='My API'),
]

Django ASGI applications can also mount/use FlexDocASGI; Django WSGI applications can use FlexDocWSGI. django_urlpatterns() is the first-class native URL-routing helper.

Architecture

FlexDocHost synchronously owns route matching, the HTML bootstrap, renderer fingerprinting, cache policy, and packaged JS/CSS. FlexDocASGI translates that neutral response to ASGI and can expose a framework-supplied live runtime snapshot or a real native execute route when one is explicitly attached. FlexDocWSGI only translates the neutral host response. Framework helpers do not fork renderer behavior.

Pass assets_dir= to FlexDocHost, FlexDocASGI, or FlexDocWSGI only when intentionally overriding the bundled renderer assets during development.

Release files for prauga-flexdoc 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prauga-flexdoc 0.7.3
File Size Uploaded
prauga_flexdoc-0.7.3.tar.gz 300.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prauga-flexdoc 0.7.3
File Interpreter ABI Platform
prauga_flexdoc-0.7.3-py3-none-any.whl Python 3 none any Details

Total release size: 593.9 kB

Release files / prauga_flexdoc-0.7.3.tar.gz

Download URL prauga_flexdoc-0.7.3.tar.gz
Size 300.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8cecb9ba270b063139e09b4c3a26f2d457ea336f7310573d976877dc575cd421
BLAKE2b-256 checksum
How to use checksums
c5699b7a89ce6711e88e34fbfaec49d8dd88079e4de68d005d9b58b81ab08b57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / prauga_flexdoc-0.7.3-py3-none-any.whl

Download URL prauga_flexdoc-0.7.3-py3-none-any.whl
Size 293.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fd10abe13ce0dbcd279f2d0d0573a5d56f1abb172b22a321bb6c97f0fae4e97
BLAKE2b-256 checksum
How to use checksums
9aed1338a3e49ccf872955b5bebea0b0d3ad68c58bc86e96f7a25c7e67122eeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.4

2 release files

This release

0.7.3 This release

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page