Skip to content

Commit 30c4861

Browse files
committed
Walking skeletons
1 parent 20cb8bb commit 30c4861

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

scripts/schema-convert.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ const fs = require('fs');
66
const yaml = require('yaml');
77

88
function convert(filename,date) {
9-
console.log(filename);
109
const s = fs.readFileSync(filename,'utf8');
1110
let obj;
1211
try {
1312
obj = yaml.parse(s, {prettyErrors: true});
14-
//TODO: replace last segment in $id, id, and $ref with date
13+
// replace last segment of id, $id, and $ref value with date
14+
for (const p of ["id","$id","$ref"]) {
15+
if (obj[p]) {
16+
obj[p] = obj[p].replace(/\/[^\/]+$/,'/'+date);
17+
}
18+
}
1519
console.log(JSON.stringify(obj,null,2));
1620
}
1721
catch (ex) {

scripts/schema-publish.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66

77
for filename in schemas/v3*/schema.yaml ; do
88
version=$(basename $(dirname "$filename"))
9-
mkdir -p deploy/oas/$version
10-
119
lastCommitDate=$(git log -1 --format="%ad" --date=format:"%Y%m%d" "$filename")
1210

13-
echo $filename $lastCommitDate $version
14-
#TODO:
15-
# - 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
17-
# - 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
11+
echo "$filename $lastCommitDate"
12+
mkdir -p deploy/oas/$version/schema
13+
node scripts/schema-convert.js "$filename" $lastCommitDate > deploy/oas/$version/schema/$lastCommitDate.json
14+
15+
filenameBase=$(dirname "$filename")/schema-base.yaml
16+
if [ -f "$filenameBase" ]; then
17+
echo "$filenameBase $lastCommitDate"
18+
mkdir -p deploy/oas/$version/schema-base
19+
node scripts/schema-convert.js "$filenameBase" $lastCommitDate > deploy/oas/$version/schema-base/$lastCommitDate.json
20+
fi
1921
done

0 commit comments

Comments
 (0)