Skip to main content

Generate typed url_path_for functions for FastAPI applications.

Project description

Type-Safe Route URL Generator for FastAPI

Stop guessing route names. This tool analyzes your FastAPI application and generates a typed wrapper for url_path_for, giving you instant autocompletion and catching typos before they hit production.

Installation

uvx generate-fastapi-typed-routes@latest

Usage

Point the tool at your FastAPI app and tell it where to save the generated code:

uvx generate-fastapi-typed-routes@latest --app-module myapp.main:app --output myapp/routes.py

Now, instead of using the raw app.url_path_for, import your generated function:

from myapp.routes import app_url_path_for

# Complete with IDE autocompletion and type checking!
url = app_url_path_for("get_user_profile", user_id=123)

CLI Arguments

  • --app-module: The import path to your FastAPI app instance (e.g., src.main:app). You can pass this multiple times to generate helpers for multiple apps in one file.
  • --output: The file path where the generated Python code will be saved.
  • --prefix: (Optional) Custom prefix for the generated function. Defaults to the app variable name (e.g., app becomes app_url_path_for). Use this if you have multiple apps to keep things distinct.

Features

  • Zero Runtime Overhead: The generated code is just type hints and a simple wrapper.
  • IDE Autocompletion: Never type a route name manually again. Your editor will list every available route name defined in your app.
  • Refactoring Safe: Change a route name in your app, and your type checker (mypy, pyright) will flag every place usage that needs updating.
  • Multi-App Support: Easily manage routes for projects with multiple FastAPI instances.

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generate_fastapi_typed_routes-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

generate_fastapi_typed_routes-0.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file generate_fastapi_typed_routes-0.1.1.tar.gz.

File metadata

  • Download URL: generate_fastapi_typed_routes-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for generate_fastapi_typed_routes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3d0111f63e3f7c1fd90082ed3fd8ef4d4557e76292e57bc16f37a031694c958d
MD5 f79aee93637c022a41729fe8255e99bf
BLAKE2b-256 cbfdac4069d1475b1ee9b0d8c1845272dd19d1a4b1d588d6c6e472efa232b4fb

See more details on using hashes here.

File details

Details for the file generate_fastapi_typed_routes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: generate_fastapi_typed_routes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for generate_fastapi_typed_routes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a82b288d90b6910f9942cec450ba0c48ebe10767726bbe745ad0b7e3678c5be
MD5 87c054aea76dcdd2c6706be08d4a8982
BLAKE2b-256 9b6a1cfd5372503f7283614561c69a17cd24e98889b6688c458b9bcb2863a8ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page