vs-server 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vs_server-0.1.2/vs_server.egg-info → vs_server-0.1.3}/PKG-INFO +41 -7
- {vs_server-0.1.2 → vs_server-0.1.3}/README.md +40 -6
- {vs_server-0.1.2 → vs_server-0.1.3}/pyproject.toml +1 -1
- vs_server-0.1.3/vs_server/decorator/vs_controller_decorator.py +48 -0
- {vs_server-0.1.2 → vs_server-0.1.3/vs_server.egg-info}/PKG-INFO +41 -7
- vs_server-0.1.2/vs_server/decorator/vs_controller_decorator.py +0 -44
- {vs_server-0.1.2 → vs_server-0.1.3}/LICENSE.txt +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/setup.cfg +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/tests/test_product_controller.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/tests/test_server.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/tests/test_user_controller.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/decorator/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/decorator/vs_server_decorator.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/decorator/vs_server_registry.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/decorator/vs_sse_decorator.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/decorator/vs_websocket_decorator.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/docs/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/docs/vs_docs_renderer.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/factory/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/factory/vs_server_factory.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/lifecycle/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/lifecycle/vs_lifecycle.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/schema/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/schema/exceptions.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/schema/vs_server_health.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/server/__init__.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/server/vs_fast_api_server.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server/server/vs_server.py +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server.egg-info/SOURCES.txt +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server.egg-info/dependency_links.txt +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server.egg-info/requires.txt +0 -0
- {vs_server-0.1.2 → vs_server-0.1.3}/vs_server.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vs-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: HTTP server abstraction for Viveka Sutra — FastAPI wrapper with lifecycle, routing, and middleware
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
@@ -469,6 +469,38 @@ async def get_report():
|
|
|
469
469
|
|
|
470
470
|
---
|
|
471
471
|
|
|
472
|
+
## Request and Response Models
|
|
473
|
+
|
|
474
|
+
All request bodies and response models must be Pydantic models — not SQLAlchemy entities or plain dicts. This is a hard requirement of FastAPI and applies to all server implementations built on vs-server.
|
|
475
|
+
|
|
476
|
+
```python
|
|
477
|
+
from pydantic import BaseModel
|
|
478
|
+
|
|
479
|
+
class UserRequest(BaseModel):
|
|
480
|
+
name: str
|
|
481
|
+
email: str
|
|
482
|
+
|
|
483
|
+
class UserResponse(BaseModel):
|
|
484
|
+
id: str
|
|
485
|
+
name: str
|
|
486
|
+
email: str
|
|
487
|
+
|
|
488
|
+
model_config = {"from_attributes": True}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
The mapping between your SQLAlchemy entity and your Pydantic schema is your responsibility:
|
|
492
|
+
|
|
493
|
+
```
|
|
494
|
+
Request (Pydantic) → Service → Entity (SQLAlchemy) → DB
|
|
495
|
+
DB → Entity (SQLAlchemy) → Service → Response (Pydantic)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Never pass a SQLAlchemy entity as `response_model` — FastAPI will reject it at startup. Never return a SQLAlchemy entity directly from a route — serialize it first.
|
|
499
|
+
|
|
500
|
+
Keeping schemas separate from entities is intentional: the DB schema and API schema can evolve independently, and sensitive fields (e.g. `password`) are excluded from responses by default.
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
472
504
|
## HTTP Controllers
|
|
473
505
|
|
|
474
506
|
Annotate a class with `@controller` and methods with HTTP verb decorators.
|
|
@@ -520,11 +552,11 @@ All FastAPI route parameters (`response_model`, `status_code`, `tags`, `summary`
|
|
|
520
552
|
|
|
521
553
|
| Decorator | HTTP Method |
|
|
522
554
|
|---|---|
|
|
523
|
-
| `@get(path, guards=[], **kwargs)` | GET |
|
|
524
|
-
| `@post(path, guards=[], **kwargs)` | POST |
|
|
525
|
-
| `@put(path, guards=[], **kwargs)` | PUT |
|
|
526
|
-
| `@delete(path, guards=[], **kwargs)` | DELETE |
|
|
527
|
-
| `@patch(path, guards=[], **kwargs)` | PATCH |
|
|
555
|
+
| `@get(path, summary, description, guards=[], **kwargs)` | GET |
|
|
556
|
+
| `@post(path, summary, description, guards=[], **kwargs)` | POST |
|
|
557
|
+
| `@put(path, summary, description, guards=[], **kwargs)` | PUT |
|
|
558
|
+
| `@delete(path, summary, description, guards=[], **kwargs)` | DELETE |
|
|
559
|
+
| `@patch(path, summary, description, guards=[], **kwargs)` | PATCH |
|
|
528
560
|
|
|
529
561
|
Guards on a method are merged with controller-level guards — both run.
|
|
530
562
|
|
|
@@ -1164,8 +1196,10 @@ Route decorators. Applied to methods inside a `@controller` class.
|
|
|
1164
1196
|
| Parameter | Type | Required | Default | Description |
|
|
1165
1197
|
|---|---|---|---|---|
|
|
1166
1198
|
| `path` | `str` | No | `""` | Route path appended to the controller prefix |
|
|
1199
|
+
| `summary` | `str` | No | `None` | Short one-line description shown in Swagger |
|
|
1200
|
+
| `description` | `str` | No | `None` | Longer description shown in Swagger |
|
|
1167
1201
|
| `guards` | `List[Callable]` | No | `[]` | Merged with controller guards |
|
|
1168
|
-
| `**kwargs` | — | No | — | Passed to the underlying FastAPI route decorator (e.g. `response_model`, `status_code
|
|
1202
|
+
| `**kwargs` | — | No | — | Passed to the underlying FastAPI route decorator (e.g. `response_model`, `status_code`) |
|
|
1169
1203
|
|
|
1170
1204
|
---
|
|
1171
1205
|
|
|
@@ -250,6 +250,38 @@ async def get_report():
|
|
|
250
250
|
|
|
251
251
|
---
|
|
252
252
|
|
|
253
|
+
## Request and Response Models
|
|
254
|
+
|
|
255
|
+
All request bodies and response models must be Pydantic models — not SQLAlchemy entities or plain dicts. This is a hard requirement of FastAPI and applies to all server implementations built on vs-server.
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from pydantic import BaseModel
|
|
259
|
+
|
|
260
|
+
class UserRequest(BaseModel):
|
|
261
|
+
name: str
|
|
262
|
+
email: str
|
|
263
|
+
|
|
264
|
+
class UserResponse(BaseModel):
|
|
265
|
+
id: str
|
|
266
|
+
name: str
|
|
267
|
+
email: str
|
|
268
|
+
|
|
269
|
+
model_config = {"from_attributes": True}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The mapping between your SQLAlchemy entity and your Pydantic schema is your responsibility:
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
Request (Pydantic) → Service → Entity (SQLAlchemy) → DB
|
|
276
|
+
DB → Entity (SQLAlchemy) → Service → Response (Pydantic)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Never pass a SQLAlchemy entity as `response_model` — FastAPI will reject it at startup. Never return a SQLAlchemy entity directly from a route — serialize it first.
|
|
280
|
+
|
|
281
|
+
Keeping schemas separate from entities is intentional: the DB schema and API schema can evolve independently, and sensitive fields (e.g. `password`) are excluded from responses by default.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
253
285
|
## HTTP Controllers
|
|
254
286
|
|
|
255
287
|
Annotate a class with `@controller` and methods with HTTP verb decorators.
|
|
@@ -301,11 +333,11 @@ All FastAPI route parameters (`response_model`, `status_code`, `tags`, `summary`
|
|
|
301
333
|
|
|
302
334
|
| Decorator | HTTP Method |
|
|
303
335
|
|---|---|
|
|
304
|
-
| `@get(path, guards=[], **kwargs)` | GET |
|
|
305
|
-
| `@post(path, guards=[], **kwargs)` | POST |
|
|
306
|
-
| `@put(path, guards=[], **kwargs)` | PUT |
|
|
307
|
-
| `@delete(path, guards=[], **kwargs)` | DELETE |
|
|
308
|
-
| `@patch(path, guards=[], **kwargs)` | PATCH |
|
|
336
|
+
| `@get(path, summary, description, guards=[], **kwargs)` | GET |
|
|
337
|
+
| `@post(path, summary, description, guards=[], **kwargs)` | POST |
|
|
338
|
+
| `@put(path, summary, description, guards=[], **kwargs)` | PUT |
|
|
339
|
+
| `@delete(path, summary, description, guards=[], **kwargs)` | DELETE |
|
|
340
|
+
| `@patch(path, summary, description, guards=[], **kwargs)` | PATCH |
|
|
309
341
|
|
|
310
342
|
Guards on a method are merged with controller-level guards — both run.
|
|
311
343
|
|
|
@@ -945,8 +977,10 @@ Route decorators. Applied to methods inside a `@controller` class.
|
|
|
945
977
|
| Parameter | Type | Required | Default | Description |
|
|
946
978
|
|---|---|---|---|---|
|
|
947
979
|
| `path` | `str` | No | `""` | Route path appended to the controller prefix |
|
|
980
|
+
| `summary` | `str` | No | `None` | Short one-line description shown in Swagger |
|
|
981
|
+
| `description` | `str` | No | `None` | Longer description shown in Swagger |
|
|
948
982
|
| `guards` | `List[Callable]` | No | `[]` | Merged with controller guards |
|
|
949
|
-
| `**kwargs` | — | No | — | Passed to the underlying FastAPI route decorator (e.g. `response_model`, `status_code
|
|
983
|
+
| `**kwargs` | — | No | — | Passed to the underlying FastAPI route decorator (e.g. `response_model`, `status_code`) |
|
|
950
984
|
|
|
951
985
|
---
|
|
952
986
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vs-server"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "HTTP server abstraction for Viveka Sutra — FastAPI wrapper with lifecycle, routing, and middleware"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from typing import Callable, List, Type
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def controller(path: str, description: str = "", guards: List[Callable] = None):
|
|
5
|
+
def decorator(cls: Type) -> Type:
|
|
6
|
+
cls._vs_controller = {
|
|
7
|
+
"path": path,
|
|
8
|
+
"description": description,
|
|
9
|
+
"guards": guards or [],
|
|
10
|
+
}
|
|
11
|
+
return cls
|
|
12
|
+
return decorator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _route(method: str, path: str = "", guards: List[Callable] = None, summary: str = None, description: str = None, **kwargs):
|
|
16
|
+
def decorator(fn: Callable) -> Callable:
|
|
17
|
+
fn._vs_route = {
|
|
18
|
+
"method": method,
|
|
19
|
+
"path": path,
|
|
20
|
+
"guards": guards or [],
|
|
21
|
+
"kwargs": {
|
|
22
|
+
**({"summary": summary} if summary else {}),
|
|
23
|
+
**({"description": description} if description else {}),
|
|
24
|
+
**kwargs,
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
return fn
|
|
28
|
+
return decorator
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get(path: str = "", guards: List[Callable] = None, summary: str = None, description: str = None, **kwargs):
|
|
32
|
+
return _route("GET", path, guards=guards, summary=summary, description=description, **kwargs)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def post(path: str = "", guards: List[Callable] = None, summary: str = None, description: str = None, **kwargs):
|
|
36
|
+
return _route("POST", path, guards=guards, summary=summary, description=description, **kwargs)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def put(path: str = "", guards: List[Callable] = None, summary: str = None, description: str = None, **kwargs):
|
|
40
|
+
return _route("PUT", path, guards=guards, summary=summary, description=description, **kwargs)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def delete(path: str = "", guards: List[Callable] = None, summary: str = None, description: str = None, **kwargs):
|
|
44
|
+
return _route("DELETE", path, guards=guards, summary=summary, description=description, **kwargs)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def patch(path: str = "", guards: List[Callable] = None, summary: str = None, description: str = None, **kwargs):
|
|
48
|
+
return _route("PATCH", path, guards=guards, summary=summary, description=description, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vs-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: HTTP server abstraction for Viveka Sutra — FastAPI wrapper with lifecycle, routing, and middleware
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
@@ -469,6 +469,38 @@ async def get_report():
|
|
|
469
469
|
|
|
470
470
|
---
|
|
471
471
|
|
|
472
|
+
## Request and Response Models
|
|
473
|
+
|
|
474
|
+
All request bodies and response models must be Pydantic models — not SQLAlchemy entities or plain dicts. This is a hard requirement of FastAPI and applies to all server implementations built on vs-server.
|
|
475
|
+
|
|
476
|
+
```python
|
|
477
|
+
from pydantic import BaseModel
|
|
478
|
+
|
|
479
|
+
class UserRequest(BaseModel):
|
|
480
|
+
name: str
|
|
481
|
+
email: str
|
|
482
|
+
|
|
483
|
+
class UserResponse(BaseModel):
|
|
484
|
+
id: str
|
|
485
|
+
name: str
|
|
486
|
+
email: str
|
|
487
|
+
|
|
488
|
+
model_config = {"from_attributes": True}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
The mapping between your SQLAlchemy entity and your Pydantic schema is your responsibility:
|
|
492
|
+
|
|
493
|
+
```
|
|
494
|
+
Request (Pydantic) → Service → Entity (SQLAlchemy) → DB
|
|
495
|
+
DB → Entity (SQLAlchemy) → Service → Response (Pydantic)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Never pass a SQLAlchemy entity as `response_model` — FastAPI will reject it at startup. Never return a SQLAlchemy entity directly from a route — serialize it first.
|
|
499
|
+
|
|
500
|
+
Keeping schemas separate from entities is intentional: the DB schema and API schema can evolve independently, and sensitive fields (e.g. `password`) are excluded from responses by default.
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
472
504
|
## HTTP Controllers
|
|
473
505
|
|
|
474
506
|
Annotate a class with `@controller` and methods with HTTP verb decorators.
|
|
@@ -520,11 +552,11 @@ All FastAPI route parameters (`response_model`, `status_code`, `tags`, `summary`
|
|
|
520
552
|
|
|
521
553
|
| Decorator | HTTP Method |
|
|
522
554
|
|---|---|
|
|
523
|
-
| `@get(path, guards=[], **kwargs)` | GET |
|
|
524
|
-
| `@post(path, guards=[], **kwargs)` | POST |
|
|
525
|
-
| `@put(path, guards=[], **kwargs)` | PUT |
|
|
526
|
-
| `@delete(path, guards=[], **kwargs)` | DELETE |
|
|
527
|
-
| `@patch(path, guards=[], **kwargs)` | PATCH |
|
|
555
|
+
| `@get(path, summary, description, guards=[], **kwargs)` | GET |
|
|
556
|
+
| `@post(path, summary, description, guards=[], **kwargs)` | POST |
|
|
557
|
+
| `@put(path, summary, description, guards=[], **kwargs)` | PUT |
|
|
558
|
+
| `@delete(path, summary, description, guards=[], **kwargs)` | DELETE |
|
|
559
|
+
| `@patch(path, summary, description, guards=[], **kwargs)` | PATCH |
|
|
528
560
|
|
|
529
561
|
Guards on a method are merged with controller-level guards — both run.
|
|
530
562
|
|
|
@@ -1164,8 +1196,10 @@ Route decorators. Applied to methods inside a `@controller` class.
|
|
|
1164
1196
|
| Parameter | Type | Required | Default | Description |
|
|
1165
1197
|
|---|---|---|---|---|
|
|
1166
1198
|
| `path` | `str` | No | `""` | Route path appended to the controller prefix |
|
|
1199
|
+
| `summary` | `str` | No | `None` | Short one-line description shown in Swagger |
|
|
1200
|
+
| `description` | `str` | No | `None` | Longer description shown in Swagger |
|
|
1167
1201
|
| `guards` | `List[Callable]` | No | `[]` | Merged with controller guards |
|
|
1168
|
-
| `**kwargs` | — | No | — | Passed to the underlying FastAPI route decorator (e.g. `response_model`, `status_code
|
|
1202
|
+
| `**kwargs` | — | No | — | Passed to the underlying FastAPI route decorator (e.g. `response_model`, `status_code`) |
|
|
1169
1203
|
|
|
1170
1204
|
---
|
|
1171
1205
|
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from typing import Callable, List, Type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def controller(path: str, description: str = "", guards: List[Callable] = None):
|
|
5
|
-
def decorator(cls: Type) -> Type:
|
|
6
|
-
cls._vs_controller = {
|
|
7
|
-
"path": path,
|
|
8
|
-
"description": description,
|
|
9
|
-
"guards": guards or [],
|
|
10
|
-
}
|
|
11
|
-
return cls
|
|
12
|
-
return decorator
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def _route(method: str, path: str = "", guards: List[Callable] = None, **kwargs):
|
|
16
|
-
def decorator(fn: Callable) -> Callable:
|
|
17
|
-
fn._vs_route = {
|
|
18
|
-
"method": method,
|
|
19
|
-
"path": path,
|
|
20
|
-
"guards": guards or [],
|
|
21
|
-
"kwargs": kwargs,
|
|
22
|
-
}
|
|
23
|
-
return fn
|
|
24
|
-
return decorator
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def get(path: str = "", guards: List[Callable] = None, **kwargs):
|
|
28
|
-
return _route("GET", path, guards=guards, **kwargs)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def post(path: str = "", guards: List[Callable] = None, **kwargs):
|
|
32
|
-
return _route("POST", path, guards=guards, **kwargs)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def put(path: str = "", guards: List[Callable] = None, **kwargs):
|
|
36
|
-
return _route("PUT", path, guards=guards, **kwargs)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def delete(path: str = "", guards: List[Callable] = None, **kwargs):
|
|
40
|
-
return _route("DELETE", path, guards=guards, **kwargs)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def patch(path: str = "", guards: List[Callable] = None, **kwargs):
|
|
44
|
-
return _route("PATCH", path, guards=guards, **kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|