Skip to content

Commit 101c2e0

Browse files
authored
chore: Factorise common CODEGEN arguments (#948)
Also normalise to tabs alignements within the *CODEGEN variables, this is a single character on the command line instead of 4 when executing the command. This counts towards the maximum size of the arguments string the shell supports.
1 parent 2e2ac7c commit 101c2e0

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

Makefile

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,36 @@
11
AMALTHEA_JS_VERSION ?= 0.20.0
22
AMALTHEA_SESSIONS_VERSION ?= 0.20.0
3-
CODEGEN_PARAMS := \
4-
--input-file-type openapi \
5-
--output-model-type pydantic_v2.BaseModel \
6-
--use-double-quotes \
7-
--target-python-version 3.13 \
8-
--collapse-root-models \
9-
--field-constraints \
10-
--strict-nullable \
11-
--set-default-enum-member \
12-
--openapi-scopes schemas paths parameters \
13-
--set-default-enum-member \
14-
--use-one-literal-as-default \
15-
--use-default
16-
CR_CODEGEN_PARAMS := \
17-
--input-file-type jsonschema \
3+
COMMON_CODEGEN_PARAMS := \
184
--output-model-type pydantic_v2.BaseModel \
195
--use-double-quotes \
206
--target-python-version 3.13 \
21-
--collapse-root-models \
227
--field-constraints \
23-
--strict-nullable \
8+
--strict-nullable
9+
API_CODEGEN_PARAMS := \
10+
--input-file-type openapi \
11+
${COMMON_CODEGEN_PARAMS} \
12+
--collapse-root-models \
13+
--set-default-enum-member \
14+
--openapi-scopes schemas paths parameters \
15+
--use-one-literal-as-default \
16+
--use-default
17+
CR_CODEGEN_PARAMS := \
18+
--input-file-type jsonschema \
19+
${COMMON_CODEGEN_PARAMS} \
20+
--collapse-root-models \
2421
--allow-extra-fields \
2522
--use-default-kwarg
2623

2724
# A separate set of params without the --collaps-root-models option as
2825
# this causes a bug in the code generator related to list of unions.
2926
# https://github.com/koxudaxi/datamodel-code-generator/issues/1937
3027
SEARCH_CODEGEN_PARAMS := \
31-
--input-file-type openapi \
32-
--output-model-type pydantic_v2.BaseModel \
33-
--use-double-quotes \
34-
--target-python-version 3.13 \
35-
--field-constraints \
36-
--strict-nullable \
37-
--set-default-enum-member \
38-
--openapi-scopes schemas paths parameters \
39-
--set-default-enum-member \
40-
--use-one-literal-as-default \
41-
--use-default
28+
--input-file-type openapi \
29+
${COMMON_CODEGEN_PARAMS} \
30+
--set-default-enum-member \
31+
--openapi-scopes schemas paths parameters \
32+
--use-one-literal-as-default \
33+
--use-default
4234

4335
.PHONY: all
4436
all: help
@@ -193,7 +185,7 @@ help: ## Display this help.
193185

194186
# Pattern rules
195187

196-
API_SPEC_CODEGEN_PARAMS := ${CODEGEN_PARAMS}
188+
API_SPEC_CODEGEN_PARAMS := ${API_CODEGEN_PARAMS}
197189
%/apispec.py: %/api.spec.yaml
198190
$(if $(findstring /search/, $(<)), $(eval API_SPEC_CODEGEN_PARAMS=${SEARCH_CODEGEN_PARAMS}))
199191
poetry run datamodel-codegen --input $< --output $@ --base-class $(subst /,.,$(subst .py,_base.BaseAPISpec,$(subst components/,,$@))) ${API_SPEC_CODEGEN_PARAMS}

0 commit comments

Comments
 (0)