Use JSON schemas for Sienna model intermediary layer #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Schema Generation | |
on: | |
push: | |
branches: | |
- main | |
tags: ["*"] | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
python-version: "3.11" | |
miniforge-version: latest | |
- name: Installing python dependencies | |
run: | | |
pip install datamodel-code-generator pre-commit | |
pip install '.[dev]' # pytest primarily | |
shell: bash -l {0} | |
- name: Run datamodel-generation | |
shell: bash -l {0} | |
run: | | |
datamodel-codegen --input schemas --input-file-type jsonschema --output python_models --output-model pydantic_v2.BaseModel | |
PYTHONPATH=. pytest test/load_models.py | |
- name: Run openapi-generation for python | |
shell: bash -l {0} | |
run: | | |
docker run --rm --user $(id -u):$(id -g) \ | |
-v ${PWD}:/local openapitools/openapi-generator-cli generate \ | |
-i /local/openapi.json \ | |
-g python \ | |
-o /local/out/python | |
- uses: julia-actions/cache@v2 | |
- name: Run openapi-generation for julia | |
shell: bash -l {0} | |
run: | | |
docker run --rm --user $(id -u):$(id -g) \ | |
-v ${PWD}:/local openapitools/openapi-generator-cli generate \ | |
-i /local/openapi.json \ | |
-g julia-server \ | |
-o /local/out/julia | |
julia -e 'import Pkg; Pkg.add("JuliaFormatter")' | |
julia -e 'using JuliaFormatter; format("out/julia")' | |
diff SiennaOpenAPIModels.jl/src/models out/julia/src/models |