Skip to content

Commit 9c26934

Browse files
committed
fix: update docs for client generation
1 parent eab6ee4 commit 9c26934

File tree

5 files changed

+789
-13
lines changed

5 files changed

+789
-13
lines changed

README.rst

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ Built on years of real-world WebSocket development experience, Chanx provides pr
106106
Installation
107107
------------
108108

109-
**Basic Installation (Core Only)**
110-
111-
.. code-block:: bash
112-
113-
pip install chanx
114-
115109
**For Django Channels Projects**
116110

117111
.. code-block:: bash
@@ -124,6 +118,18 @@ Installation
124118
125119
pip install "chanx[fast_channels]"
126120
121+
**For Client Generator CLI**
122+
123+
.. code-block:: bash
124+
125+
pip install "chanx[cli]"
126+
127+
**For Using Generated Clients**
128+
129+
.. code-block:: bash
130+
131+
pip install "chanx[client]"
132+
127133
128134
Prerequisites
129135
-------------
@@ -381,6 +387,9 @@ Key Features
381387
**AsyncAPI 3.0 Generation**
382388
Auto-generate interactive documentation and OpenAPI-style specs from decorated handlers
383389

390+
**Type-Safe Client Generator**
391+
Generate Python WebSocket clients from AsyncAPI schemas with full type safety and IDE support
392+
384393
**Authentication System**
385394
Built-in ``DjangoAuthenticator`` with DRF permission support, extensible ``BaseAuthenticator`` for custom flows
386395

@@ -396,11 +405,37 @@ Key Features
396405
**Configuration Management**
397406
Django settings integration via ``CHANX`` dict, class-level config for FastAPI consumers
398407

408+
Client Generator
409+
----------------
410+
411+
Generate type-safe Python clients from your AsyncAPI schema:
412+
413+
.. code-block:: bash
414+
415+
# Generate from local file (JSON or YAML)
416+
chanx generate-client --schema asyncapi.json --output ./my_client
417+
chanx generate-client --schema asyncapi.yaml --output ./my_client
418+
419+
# Generate directly from URL (no need to download)
420+
chanx generate-client --schema http://localhost:8000/asyncapi.json --output ./my_client
421+
422+
.. code-block:: python
423+
424+
# Use generated client with full type safety
425+
from my_client.chat import ChatClient, ChatMessage, ChatPayload
426+
427+
client = ChatClient("localhost:8000")
428+
429+
await client.send_message(
430+
ChatMessage(payload=ChatPayload(message="Hello!"))
431+
)
432+
399433
Learn More
400434
----------
401435

402436
* `Documentation <https://chanx.readthedocs.io/>`_ - Complete guide and API reference
403437
* `Django Quick Start <https://chanx.readthedocs.io/en/latest/quick-start-django.html>`_ - Django-specific setup
404438
* `FastAPI Quick Start <https://chanx.readthedocs.io/en/latest/quick-start-fastapi.html>`_ - FastAPI-specific setup
405439
* `User Guide <https://chanx.readthedocs.io/en/latest/user-guide/prerequisites.html>`_ - In-depth features and patterns
440+
* `Client Generator Guide <https://chanx.readthedocs.io/en/latest/user-guide/client-generator.html>`_ - Generate type-safe clients
406441
* `Examples <https://chanx.readthedocs.io/en/latest/examples/django.html>`_ - Real-world implementation examples

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Contents
2424
user-guide/asyncapi
2525
user-guide/testing
2626
user-guide/framework-integration
27+
user-guide/client-generator
2728
comparison
2829

2930
.. toctree::

docs/installation.rst

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ Framework-specific dependencies are installed automatically based on which extra
1414

1515
Installing Chanx
1616
----------------
17-
**Basic Installation (Core Only)**
18-
19-
.. code-block:: bash
20-
21-
pip install chanx
2217

2318
**For Django Channels Projects**
2419

@@ -28,10 +23,11 @@ Installing Chanx
2823
2924
This installs:
3025

26+
- Pydantic 2.0+ (validation)
3127
- Django 5.0+
3228
- Django Channels 4.0+
3329
- Django REST Framework 3.0+
34-
- Channels Redis 4.0+
30+
- Core dependencies (pyhumps, structlog, typing-extensions)
3531

3632
**For FastAPI and Other ASGI Frameworks**
3733

@@ -41,8 +37,47 @@ This installs:
4137
4238
This installs:
4339

40+
- Pydantic 2.0+ (validation)
4441
- FastAPI 0.117+
4542
- fast-channels 1.0+
43+
- Core dependencies (pyhumps, structlog, typing-extensions)
44+
45+
**For Client Generator CLI + Generated Clients**
46+
47+
If you need both the CLI tool (for generating clients) and the ability to use generated clients:
48+
49+
.. code-block:: bash
50+
51+
# Using pip
52+
pip install "chanx[cli,client]"
53+
54+
# Using uv (recommended approach)
55+
uv add chanx[client] # Runtime dependency
56+
uv add --group dev chanx[cli] # Development dependency
57+
58+
This installs:
59+
60+
- **Runtime (client)**: Pydantic 2.0+, websockets
61+
- **Development (cli)**: click, httpx, jinja2, pyyaml (for code generation)
62+
63+
**For Using Generated Clients Only**
64+
65+
If you only need to use a generated client (not generate new ones):
66+
67+
.. code-block:: bash
68+
69+
# Using pip
70+
pip install "chanx[client]"
71+
72+
# Using uv
73+
uv add chanx[client]
74+
75+
This installs only:
76+
77+
- Pydantic 2.0+ (for message validation)
78+
- websockets (for WebSocket connectivity)
79+
80+
No CLI tools, no server dependencies - just what's needed to run the generated client code.
4681

4782
**Install from Source**
4883

@@ -130,12 +165,33 @@ Chanx includes automatic camelCase conversion. Enable it in your configuration:
130165
camelize = True
131166
132167
168+
CLI Usage
169+
---------
170+
171+
Once installed, you can use the client generator CLI with local files or URLs:
172+
173+
.. code-block:: bash
174+
175+
# Generate from local file (JSON or YAML)
176+
chanx generate-client --schema asyncapi.json --output ./my_client
177+
chanx generate-client --schema asyncapi.yaml --output ./my_client
178+
179+
# Generate directly from URL (no download needed)
180+
chanx generate-client --schema http://localhost:8000/asyncapi.json --output ./my_client
181+
chanx generate-client --schema https://api.example.com/asyncapi.yaml --output ./my_client
182+
183+
# With custom formatter
184+
chanx generate-client --schema asyncapi.json --output ./my_client --formatter "black"
185+
186+
See :doc:`user-guide/client-generator` for complete CLI documentation.
187+
133188
Next Steps
134189
----------
135190
Now that you have Chanx installed, proceed to:
136191

137192
* :doc:`quick-start-django` - Create your first Django WebSocket consumer
138193
* :doc:`quick-start-fastapi` - Create your first FastAPI WebSocket consumer
194+
* :doc:`user-guide/client-generator` - Generate type-safe Python clients
139195
* :doc:`user-guide/prerequisites` - Start with the user guide prerequisites
140196
* :doc:`examples/django` - See Django implementation examples
141197
* :doc:`examples/fastapi` - See FastAPI implementation examples

docs/introduction.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ How Chanx Solves This
119119
# ✅ Pydantic validates at runtime
120120
# ✅ Framework auto-generates discriminated unions
121121
122-
**3. Auto-Generated Documentation - Always Up-to-Date**
122+
**3. Auto-Generated Documentation & Type-Safe Clients**
123123

124124
.. code-block:: python
125125
@@ -137,6 +137,26 @@ How Chanx Solves This
137137
:alt: AsyncAPI Documentation automatically generated from Chanx decorators
138138
:align: center
139139

140+
**Generate Type-Safe Python Clients**
141+
142+
.. code-block:: bash
143+
144+
# Generate from local file or URL (JSON/YAML supported)
145+
chanx generate-client --schema asyncapi.json --output ./my_client
146+
chanx generate-client --schema http://localhost:8000/asyncapi.json --output ./my_client
147+
148+
.. code-block:: python
149+
150+
# Use generated client with full type safety
151+
from my_client.chat import ChatClient, ChatMessage, ChatPayload
152+
153+
client = ChatClient("localhost:8000")
154+
await client.send_message(
155+
ChatMessage(payload=ChatPayload(message="Hello!"))
156+
)
157+
158+
See :doc:`user-guide/client-generator` for complete client generation guide.
159+
140160
**4. Multi-Framework Support - Works Everywhere**
141161

142162
.. code-block:: python

0 commit comments

Comments
 (0)