Skip to content

Commit a7cb73f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into main-schema-test-coverage
2 parents f9cd70a + ac6ba3d commit a7cb73f

File tree

9 files changed

+120
-9
lines changed

9 files changed

+120
-9
lines changed

.github/workflows/respec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
delete-branch: true
5050
path: deploy
5151
labels: Housekeeping
52-
reviewers: webron,darrelmiller
52+
reviewers: darrelmiller,webron,earth2marsh,webron,lornajane,mikekistler,miqui,ralfhandl,handrews,karenetheridge
5353
title: Update ReSpec-rendered specification versions
5454
commit-message: Update ReSpec-rendered specification versions
5555
signoff: true

.github/workflows/schema-publish.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: schema-publish
2+
3+
# author: @ralfhandl
4+
# issue: https://github.com/OAI/OpenAPI-Specification/issues/3715
5+
6+
#
7+
# This workflow copies the 3.x schemas to the gh-pages branch
8+
#
9+
10+
# run this on push to main
11+
on:
12+
push:
13+
branches:
14+
- main
15+
workflow_dispatch: {}
16+
17+
jobs:
18+
publish:
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4 # checkout main branch
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: actions/setup-node@v4 # setup Node.js
28+
with:
29+
node-version: '20.x'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- uses: actions/checkout@v4 # checkout gh-pages branch
35+
with:
36+
ref: gh-pages
37+
path: deploy
38+
39+
- name: run main script
40+
run: scripts/schema-publish.sh
41+
42+
- name: Create Pull Request
43+
uses: peter-evans/create-pull-request@v6
44+
with:
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
branch: publish-schema-iteration
47+
base: gh-pages
48+
delete-branch: true
49+
path: deploy
50+
labels: Housekeeping,Schema
51+
reviewers: darrelmiller,webron,earth2marsh,webron,lornajane,mikekistler,miqui,ralfhandl,handrews,karenetheridge
52+
title: Publish OpenAPI Metaschema Iterations
53+
commit-message: New OpenAPI metaschema iterations
54+
signoff: true
55+
body: |
56+
This pull request is automatically triggered by GitHub action `schema-publish`.
57+
The `schemas/**/*.yaml` files have changed and JSON files are automatically generated.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ This GitHub project is the starting point for OpenAPI. Here you will find the in
1919

2020
This repository contains [the Markdown sources](versions) for [all published OpenAPI Specification versions](https://spec.openapis.org/). For release notes and release candidate versions, refer to the [releases page](releases).
2121

22-
Each folder in this repository, such as [examples](examples) and [schemas](schemas), should contain folders pertaining to the current and previous versions of the specification.
22+
Each folder in this repository, such as [schemas](schemas) and [tests](tests), should contain folders pertaining to the current and previous versions of the specification.
2323

2424
## See It in Action
2525

26-
If you just want to see it work, check out the [list of current examples](examples).
26+
If you just want to see it work, check out the [list of current examples](https://learn.openapis.org/examples/).
2727

2828
## Tools and Libraries
2929

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"yargs": "^17.7.2"
3030
},
3131
"devDependencies": {
32-
"@hyperjump/json-schema": "^1.9.8",
32+
"@hyperjump/json-schema": "^1.9.9",
3333
"c8": "^10.1.2",
3434
"markdownlint-cli": "^0.42.0",
3535
"mdv": "^1.3.4",
File renamed without changes.
File renamed without changes.

scripts/schema-publish.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
# Author: @ralfhandl
4+
5+
# Run this script from the root of the repo. It is designed to be run by a GitHub workflow.
6+
7+
for schemaDir in schemas/v3* ; do
8+
vVersion=$(basename "$schemaDir")
9+
version=${vVersion:1}
10+
echo $version
11+
12+
# list of schemas to process, dependent schemas come first
13+
schemas=(meta.yaml dialect.yaml schema.yaml schema-base.yaml)
14+
15+
# find the newest commit date for each schema
16+
maxDate=""
17+
declare -A datesHash
18+
for schema in "${schemas[@]}"; do
19+
if [ -f "$schemaDir/$schema" ]; then
20+
newestCommitDate=$(git log -1 --format="%ad" --date=short "$schemaDir/$schema")
21+
22+
# the newest date across a schema and all its dependencies is its date stamp
23+
if [ "$newestCommitDate" \> "$maxDate" ]; then
24+
maxDate=$newestCommitDate
25+
fi
26+
datesHash["$schema"]=$maxDate
27+
echo $schema changed at $newestCommitDate
28+
fi
29+
done
30+
31+
# construct sed command
32+
sedCmd=()
33+
for schema in "${!datesHash[@]}"; do
34+
base=$(basename "$schema" .yaml)
35+
sedCmd+=("-e s/$base\/WORK-IN-PROGRESS/$base\/${datesHash[$schema]}/g")
36+
done
37+
38+
# create the date-stamped schemas
39+
for schema in "${!datesHash[@]}"; do
40+
base=$(basename "$schema" .yaml)
41+
target=deploy/oas/$version/$base/${datesHash[$schema]}
42+
43+
mkdir -p "deploy/oas/$version/$base"
44+
45+
sed ${sedCmd[@]} $schemaDir/$schema > $target.yaml
46+
node scripts/yaml2json/yaml2json.js $target.yaml
47+
rm $target.yaml
48+
mv $target.json $target
49+
50+
mv deploy/oas/$version/$base/*.md $target.md
51+
done
52+
53+
echo ""
54+
done

scripts/yaml2json/yaml2json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require('fs');
66
const yaml = require('yaml');
77

88
function convert(filename) {
9-
console.log(filename);
9+
// console.log(filename);
1010
const s = fs.readFileSync(filename,'utf8');
1111
let obj;
1212
try {

0 commit comments

Comments
 (0)