master > master: code py - models + config implementiert
This commit is contained in:
@@ -11,6 +11,7 @@ _default:
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
PYTHON := if os_family() == "windows" { "py -3" } else { "python3" }
|
||||
GEN_MODELS := "datamodel-codegen"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Macros
|
||||
@@ -42,6 +43,19 @@ _docker-build-and-log service:
|
||||
_docker-build-and-interact service container:
|
||||
@docker compose up --build -d {{service}} && docker attach {{container}}
|
||||
|
||||
_generate-models path name:
|
||||
@{{GEN_MODELS}} \
|
||||
--input-file-type openapi \
|
||||
--encoding "UTF-8" \
|
||||
--disable-timestamp \
|
||||
--use-schema-description \
|
||||
--allow-population-by-field-name \
|
||||
--snake-case-field \
|
||||
--strict-nullable \
|
||||
--target-python-version 3.9 \
|
||||
--input {{path}}/{{name}}-schema.yaml \
|
||||
--output {{path}}/generated/{{name}}.py
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# TARGETS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -50,8 +64,16 @@ _docker-build-and-interact service container:
|
||||
# TARGETS: build
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
build:
|
||||
build: _build-requirements _build-skip-requirements
|
||||
_build-skip-requirements: build-models
|
||||
_build-requirements:
|
||||
@{{PYTHON}} -m pip install --disable-pip-version-check -r requirements.txt
|
||||
build-models: _check-system-requirements _build-models-nochecks
|
||||
_build-models-nochecks:
|
||||
@echo "Generate data models from schemata."
|
||||
@just _create-folder-if-not-exists "models/generated"
|
||||
@- just _generate-models "models" "config"
|
||||
@- just _generate-models "models" "commands"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# TARGETS: run
|
||||
@@ -145,3 +167,8 @@ _display-logs:
|
||||
check-system:
|
||||
@echo "Operating System detected: {{os_family()}}."
|
||||
@echo "Python command used: {{PYTHON}}."
|
||||
_check-system-requirements:
|
||||
@if ! ( {{GEN_MODELS}} --help >> /dev/null 2> /dev/null ); then \
|
||||
echo "Command '{{GEN_MODELS}}' did not work. Ensure that the installation of 'datamodel-code-generator' worked and that system paths are set." \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user