File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Generate TypeScript Classes from JSONSchemas
2+ on :
3+ push :
4+ paths :
5+ - " json_schemas/**.json"
6+ jobs :
7+ generate :
8+ name : Generate TypeScript Classes from JSONSchemas
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Check out Git repository
12+ uses : actions/checkout@v2
13+ - name : Set up Node.js
14+ uses : actions/setup-node@v1
15+ with :
16+ node-version : 14
17+ - name : Install Code Generator
18+ run : npm install json-schema-to-typescript -g
19+ - name : Run Code Generator
20+ run : json2ts -i 'json_schemas/**.json' -o ts_models/
21+ - name : Upload TypeScript Files
22+ uses : actions/upload-artifact@master
23+ with :
24+ name : TypeScriptClasses
25+ path : ts_models
26+ - name : Push ts_models content to type script models repo
27+ 28+ env :
29+ API_TOKEN_GITHUB : ${{ secrets.TS_MODELS_PUSH_TOKEN }}
30+ with :
31+ source-directory : " ts_models"
32+ target-directory : " src"
33+ destination-github-username : " Hochfrequenz"
34+ destination-repository-name : " ahbicht-ts-models"
35+ 36+ target-branch : main
Original file line number Diff line number Diff line change 5353 },
5454 "title" : " requirement_constraint_keys" ,
5555 "type" : " array"
56+ },
57+ "time_condition_keys" : {
58+ "items" : {
59+ "title" : " time_condition_keys" ,
60+ "type" : " string"
61+ },
62+ "title" : " time_condition_keys" ,
63+ "type" : " array"
5664 }
5765 },
5866 "type" : " object"
Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ This is thought to reduce manual efforts and allow for easy integration of AHBic
99The files in this directory are autogenerated from the marshmallow classes that are also used for (de-)serialization.
1010There is a tox environment that executes [ ` generate_json_schemas.py ` ] ( generate_json_schemas.py ) and overwrites any ` .json ` files in this directory.
1111Simply run:
12+
1213``` bash
1314tox -e json_schemas
1415```
16+
17+ ### Github Action and Type Script Models
18+
19+ The JSON Schemas in this directory are used to autogenerate TypeScript Model classes.
20+ Therefore, [ a Github Action] ( ../.github/workflows/typescript_from_json_schemas.yml ) is triggered whenever something is written to this directory.
21+ The generated classes are uploaded as Action artifact and pushed to [ ahbicht-ts-models] ( https://github.com/Hochfrequenz/ahbicht-ts-models ) .
You can’t perform that action at this time.
0 commit comments