-
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathaction.yml
More file actions
90 lines (81 loc) · 2.74 KB
/
action.yml
File metadata and controls
90 lines (81 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: 'datamodel-code-generator'
description: 'Generate Python data models from schema definitions (OpenAPI, JSON Schema, GraphQL, and more)'
branding:
icon: 'code'
color: 'blue'
inputs:
input:
description: 'Input schema file or directory'
required: true
output:
description: 'Output file or directory'
required: true
input-file-type:
description: 'Input file type (openapi, jsonschema, json, yaml, csv, graphql)'
required: true
output-model-type:
description: 'Output model type (pydantic_v2.BaseModel, pydantic_v2.dataclass, dataclasses.dataclass, typing.TypedDict, msgspec.Struct)'
required: true
check:
description: 'Validate that existing output is up to date (no generation)'
required: false
default: 'true'
working-directory:
description: 'Working directory (where pyproject.toml is located)'
required: false
default: '.'
profile:
description: 'Named profile from pyproject.toml [tool.datamodel-codegen.profiles.<name>]'
required: false
default: ''
extra-args:
description: 'Additional CLI arguments'
required: false
default: ''
version:
description: 'Specific version to install (defaults to action tag version if tag looks like a version, otherwise latest)'
required: false
default: ''
extras:
description: 'Optional extras to install (comma-separated: graphql, http, validation, ruff, all)'
required: false
default: ''
runs:
using: 'composite'
steps:
- uses: actions/setup-python@v6
with:
python-version: '3.14'
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: datamodel-codegen-${{ runner.os }}
- run: |
EXTRAS=""
if [ -n "${{ inputs.extras }}" ]; then
EXTRAS="[${{ inputs.extras }}]"
fi
if [ -n "${{ inputs.version }}" ]; then
pip install "datamodel-code-generator${EXTRAS}==${{ inputs.version }}"
elif [[ "${{ github.action_ref }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
pip install "datamodel-code-generator${EXTRAS}==${{ github.action_ref }}"
else
pip install "datamodel-code-generator${EXTRAS}"
fi
shell: bash
- run: |
ARGS=(
--input "${{ inputs.input }}"
--output "${{ inputs.output }}"
--input-file-type "${{ inputs.input-file-type }}"
--output-model-type "${{ inputs.output-model-type }}"
)
if [ "${{ inputs.check }}" = "true" ]; then
ARGS+=(--check)
fi
if [ -n "${{ inputs.profile }}" ]; then
ARGS+=(--profile "${{ inputs.profile }}")
fi
datamodel-codegen "${ARGS[@]}" ${{ inputs.extra-args }}
shell: bash
working-directory: ${{ inputs.working-directory }}