Skip to main content

fusion-framework (Python)

نسخه‌ی پایتونِ کلاس‌محور برای fusion-core (هسته‌ی Rust).

در این طراحی، منطق‌های اصلی مثل routing، parsing، serialization و binding پارامترهای handler در Rust انجام می‌شود. سمت پایتون فقط interface و DX باقی می‌ماند.

نصب

pip install fusion-framework

شروع سریع

from fusion_framework.api import FusionBaseApi
from fusion_framework.route import router
from fusion_framework.app import run

 
@router("/api/[module]/{id}")
class MyModule(FusionBaseApi):
    def get(self, id: int):
        # `id` طبق annotation به int تبدیل می‌شود (در Rust)
        return self.response({"ok": True, "id": id}, status=200)


if __name__ == "__main__":
    run()

تنظیمات Swagger

در fusion.<env>.json (همان فایلی که fusion init می‌سازد) بلاک swagger را ویرایش کن:

{
  "env": "dev",
  "config": {
    "swagger": {
      "enabled": true,
      "path": "/swagger",
      "title": "Fusion API Docs",
      "info": {
        "title": "Fusion API",
        "version": "1.0.0",
        "description": "My API docs",
        "contact": { "name": "API Support", "email": "support@example.com" },
        "license": { "name": "MIT" }
      },
      "servers": [{ "url": "/", "description": "Current host" }],
      "auth": {
        "persistAuthorization": true,
        "schemes": {
          "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" },
          "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key" }
        },
        "global": [],
        "oauth": {
          "clientId": "",
          "appName": "Fusion API",
          "scopes": "",
          "usePkceWithAuthorizationCodeGrant": true
        }
      },
      "navbar": {
        "enabled": true,
        "showUrlInput": true
      },
      "ui": {
        "deepLinking": true,
        "docExpansion": "list",
        "filter": true,
        "tryItOutEnabled": true,
        "displayRequestDuration": true
      }
    }
  }
}

معنی کلیدها

کلید کار
enabled روشن/خاموش کردن کل Swagger
path آدرس UI (پیش‌فرض /swagger)
title عنوان تب مرورگر
info متادیتای OpenAPI (title/version/description/contact/license)
servers لیست سرورها در OpenAPI (Try it out روی کدام host بزند)
auth.schemes تعریف روش‌های احراز هویت در OpenAPI (Bearer / API Key / OAuth2 / ...)
auth.global اگر پر باشد، همه‌ی endpointها به‌صورت پیش‌فرض آن security را می‌گیرند
auth.persistAuthorization توکن Authorize را بعد از رفرش صفحه نگه می‌دارد
auth.oauth تنظیمات initOAuth برای جریان OAuth2 در UI
navbar.enabled نوار بالای Swagger (Topbar) را نشان بده/پنهان کن
navbar.showUrlInput اینپوت آدرس spec داخل navbar
navbar.urls چند spec برای سوئیچ از navbar: [{ "url": "...", "name": "..." }]
ui.* بقیه‌ی گزینه‌های Swagger UI

متادیتای هر endpoint همچنان از @route(..., tags=..., desc=..., title=..., deprecated=...) می‌آید.

قرارداد Handlerها

متدهای HTTP مثل get/post/put/delete/patch را به صورت معمول پیاده کن.

  1. ورودی‌ها از طریق امضای متد (def get(self, id: int, ...)) گرفته می‌شوند.
  2. منبع مقدار بر اساس نام پارامتر:
  • اگر نام با path params یکی باشد → از path
  • اگر متد POST/PUT/PATCH باشد و نام در body JSON باشد → از body
  • در غیر این صورت اگر نام در query باشد → از query
  1. اگر پارامتری annotation/optional داشته باشد و وجود نداشته باشد → None ارسال می‌شود.

خطاها

from fusion_framework.http import HTTPException

raise HTTPException(404, {"detail": "not found"})

فایل‌های مهم

  • fusion_framework.api.FusionBaseApi
    • view درخواست: method/path/body/headers/params/query
    • helper envelope: response(...)
  • fusion_framework.route.router
    • ثبت کلاس‌ها با template مثل /api/[module]/{id}
  • fusion_framework.app.run
    • settings را لود می‌کند و برنامه را mount/listen می‌کند
  • پشت صحنه:
    • crates/fusion-py/src/lib.rs: PyO3 bridge
    • crates/fusion-core/src/*: routing/serialize/binding مشترک

Release files for fusion-framework 1.1.2

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

Source distribution (sdist)

Source distribution for fusion-framework 1.1.2
File Size Uploaded
fusion_framework-1.1.2.tar.gz 51.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for fusion-framework 1.1.2
File
fusion_framework-1.1.2-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
fusion_framework-1.1.2-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
fusion_framework-1.1.2-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
fusion_framework-1.1.2-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 3.7 MB

Release files / fusion_framework-1.1.2.tar.gz

Download URL fusion_framework-1.1.2.tar.gz
Size 51.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9261fbf5db75c7bc18f71c30c3d56fedb564e9fec2e2bd68bb801f68abd58958
BLAKE2b-256 checksum
How to use checksums
5b8be44d93da026c01bbd542c72a85e1a1f05fda1bfa07c5adfe121bd01f956f
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 Aug 12, 2026.

Transparency log

Release files / fusion_framework-1.1.2-cp39-abi3-win_amd64.whl

Download URL fusion_framework-1.1.2-cp39-abi3-win_amd64.whl
Size 780.9 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7c2edd292883f01b05c957a813c594b5d016cb00621019e551aa926fa6fe7c11
BLAKE2b-256 checksum
How to use checksums
a88d0cda92c25e28d36eca31485b4851215f81d240c2d7a38509e27926d79032
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 Aug 12, 2026.

Transparency log

Release files / fusion_framework-1.1.2-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL fusion_framework-1.1.2-cp39-abi3-manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
4553945ee6614888a571a488bd04ea21e0fd209d5d3b0a9206501dee7795147d
BLAKE2b-256 checksum
How to use checksums
a2743d79db5f8a9163f048ef405bd41a2a83cd1d754fb4e3b7bbd8417bf5776f
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 Aug 12, 2026.

Transparency log

Release files / fusion_framework-1.1.2-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL fusion_framework-1.1.2-cp39-abi3-manylinux_2_28_aarch64.whl
Size 992.0 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
eb02ae52127ab829665b5c5195adab2ce2b7946ec98bd7f3516f02075cf34203
BLAKE2b-256 checksum
How to use checksums
14812868dc87d0213b4eb836a4cb65705d2114de9ae352922a9ead3433f7dcc5
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 Aug 12, 2026.

Transparency log

Release files / fusion_framework-1.1.2-cp39-abi3-macosx_11_0_arm64.whl

Download URL fusion_framework-1.1.2-cp39-abi3-macosx_11_0_arm64.whl
Size 878.8 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7da549693a1fd09822b5fa3bda50847bc9ca2e5d3e3be6dfefc0b88a32e118b1
BLAKE2b-256 checksum
How to use checksums
0633c2b85c800547e45aca69da0205d2b15860131057752b960cc2fdb84fb27b
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 Aug 12, 2026.

Transparency log

Release history Release notifications | RSS feed

2.0.1

5 release files

2.0.0

5 release files

1.3.0

5 release files

1.2.6

5 release files

1.2.5

5 release files

1.2.4

5 release files

1.2.3

5 release files

1.2.2

5 release files

1.2.1

5 release files

1.2.0

5 release files

1.1.3

5 release files

This release

1.1.2 This release

5 release files

1.1.1

5 release files

1.1.0

5 release files

0.1.2

5 release files

0.1.1

5 release files

0.1.0

5 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