File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 2323 - name : Install core
2424 run : pip install "Django${{ matrix.django-version }}" pydantic
2525 - name : Install tests
26- run : pip install pytest pytest-asyncio pytest-django injector>=0.19.0 django-ninja asgiref contextlib2
26+ run : pip install pytest pytest-asyncio pytest-django injector>=0.19.0 django-ninja asgiref contextlib2 ninja-schema==0.13.4
2727 - name : Test
2828 run : pytest
2929 codestyle :
Original file line number Diff line number Diff line change 22
33from ninja .orm .fields import TYPES
44from ninja .params import Body , Path
5- from ninja_schema .errors import ConfigError
6- from ninja_schema .orm .factory import SchemaFactory
7- from ninja_schema .orm .model_schema import ModelSchemaConfig , ModelSchemaConfigAdapter
85
96from ninja_extra .constants import ROUTE_FUNCTION
107
1411from ..route import route
1512from .schemas import ModelConfig
1613
14+ try :
15+ from ninja_schema .errors import ConfigError
16+ from ninja_schema .orm .factory import SchemaFactory
17+ from ninja_schema .orm .model_schema import (
18+ ModelSchemaConfig ,
19+ ModelSchemaConfigAdapter ,
20+ )
21+ except Exception : # pragma: no cover
22+ ConfigError = ModelSchemaConfig = ModelSchemaConfigAdapter = SchemaFactory = None
23+
24+
1725if t .TYPE_CHECKING :
1826 from ..base import APIController , ModelControllerBase
1927
@@ -48,6 +56,11 @@ def __init__(
4856 self .generate_all_schema ()
4957
5058 def generate_all_schema (self ) -> None :
59+ if not ModelSchemaConfig : # pragma: no cover
60+ raise RuntimeError (
61+ "ninja-schema package is required for ModelControllerSchema generation.\n pip install ninja-schema"
62+ )
63+
5164 model_config = ModelSchemaConfig (
5265 "dummy" ,
5366 ModelSchemaConfigAdapter (
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ requires = [
4848 " contextlib2"
4949]
5050description-file = " README.md"
51- requires-python = " >=3.6 "
51+ requires-python = " >=3.7 "
5252
5353
5454[tool .flit .metadata .urls ]
@@ -64,6 +64,7 @@ test = [
6464 " ruff ==0.0.275" ,
6565 " black == 23.7.0" ,
6666 " injector >= 0.19.0" ,
67+ " ninja-schema>=0.13.4" ,
6768 " django-stubs" ,
6869]
6970doc = [
You can’t perform that action at this time.
0 commit comments