Add typescript support and automatic openapi client generation from ninja

This commit is contained in:
2024-10-09 16:28:54 +02:00
parent 6f4e93bb76
commit a71ca60270
10 changed files with 786 additions and 17 deletions

View File

@ -7,7 +7,7 @@ from django.contrib.staticfiles.management.commands.collectstatic import (
)
from staticfiles.apps import GENERATED_ROOT, IGNORE_PATTERNS_SCSS
from staticfiles.processors import Scss, Webpack
from staticfiles.processors import OpenApi, Scss, Webpack
class Command(CollectStatic):
@ -50,6 +50,7 @@ class Command(CollectStatic):
return Path(location)
Scss.compile(self.collect_scss())
OpenApi.compile() # This needs to be prior to webpack
Webpack.compile()
collected = super().collect()

View File

@ -6,13 +6,15 @@ from django.contrib.staticfiles.management.commands.runserver import (
)
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
from staticfiles.processors import Webpack
from staticfiles.processors import OpenApi, Webpack
class Command(Runserver):
"""Light wrapper around the statics runserver that integrates webpack auto bundling"""
def run(self, **options):
# OpenApi generation needs to be before webpack
OpenApi.compile()
# Only run webpack server when debug is enabled
# Also protects from re-launching the server if django reloads it
if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and settings.DEBUG: