File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ 'use strict' ;
4+
5+ const fs = require ( 'fs' ) ;
6+ const yaml = require ( 'yaml' ) ;
7+
8+ function convert ( filename , date ) {
9+ console . log ( filename ) ;
10+ const s = fs . readFileSync ( filename , 'utf8' ) ;
11+ let obj ;
12+ try {
13+ obj = yaml . parse ( s , { prettyErrors : true } ) ;
14+ //TODO: replace last segment in $id, id, and $ref with date
15+ console . log ( JSON . stringify ( obj , null , 2 ) ) ;
16+ }
17+ catch ( ex ) {
18+ console . warn ( ' ' , ex . message ) ;
19+ process . exitCode = 1 ;
20+ }
21+ }
22+
23+ if ( process . argv . length < 4 ) {
24+ console . warn ( 'Usage: convert-schema.js file.yaml YYYYMMDD' ) ;
25+ }
26+ else {
27+ convert ( process . argv [ 2 ] , process . argv [ 3 ] ) ;
28+ }
29+
Original file line number Diff line number Diff line change @@ -13,5 +13,7 @@ for filename in schemas/v3*/schema.yaml ; do
1313 echo $filename $lastCommitDate $version
1414 # TODO:
1515 # - generate JSON file "deploy/oas/$version/schema/$lastCommitDate" from schema.yaml
16+ # node scripts/schema-convert.js $filename $lastCommitDate > deploy/oas/$version/schema/$lastCommitDate.json
1617 # - if schema-base.yaml exists, generate JSON file "deploy/oas/$version/schema-base/$lastCommitDate" from schema-base.yaml
18+ # node scripts/schema-convert.js ... $lastCommitDate > deploy/oas/$version/schema-base/$lastCommitDate.json
1719done
You can’t perform that action at this time.
0 commit comments