Uh oh!
There was an error while loading. Please reload this page.
Update schema-publish.sh - #4376
Conversation
Uh oh!
There was an error while loading. Please reload this page.
| rm $target.yaml | ||
| mv $target.json $target | ||
| mv deploy/oas/$version/$base/*.md $target.md |
There was a problem hiding this comment.
This command seems to have been lost. It is necessary when building to deploy/ for the
- view schema/2024-11-14
links on https://spec.openapis.org to work.
There was a problem hiding this comment.
I saw that command, but couldn't reason what it was doing, since no .md files are generated in /deploy/**.
Running the script with a clean or missing /deploy makes it a no-op.
Can you point to me where the link-updating bit happens, or show me where the .md files make their way to /deploy?
There was a problem hiding this comment.
The *.md files only exist in the gh-pages branch, for example in https://github.com/OAI/OpenAPI-Specification/tree/gh-pages/oas/3.1/schema.
The title of each file is specific to that file, and I didn't want to hard-code them in the build script to minimize the differences between the OpenAPI, Overlay, and Arazzo copies of the build script.
There was a problem hiding this comment.
I'll re-add this command, but I think it indicates a weird space in the abstraction. It seems contradictory to me to both mkdir -p deploy/oas/3.1.1and to expect that there are already markdown files present there.
I also think it's a bad pattern to do a mv where the input could be multiple files, but the destination is a single file.
It looks like the file we expect to move is actually named the same as $date. Short of restoring latest, could I just move that one $date.md file?
Alternatively, we could go back to having a latest.md, but on publish, rename it to match the latest iteration of the schema. This would preserve the publishing behavior (not creating a latest link or schema), while still removing step of manually renaming the .md file with each revision and allowing us to reference a stable filename for copying in this script.
There was a problem hiding this comment.
I've pushed a change which replicates the current *.md behavior, as well as introduces some commented-out code probing the pain points mentioned in my comment above.
😐 One implementation supposes the
.mdfile's name always matches the iteration date, which matches the current setup, and is still simpler than globbing files.😄 One implementation supposes the
.mdfile is alwayslatest.md. This used to be the setup, but it was abandoned. I think this approach is best. See below for more articulation.😞 One implementation mirrors the current behavior, but selects only the "first" markdown file encountered. This aligns better with the sentiment A
mvcommand whose destination is a file should have a file as its first argument, but in a kind of nonsense way.😞 The actual implementation mirrors the current behavior, attempting to copy all the markdown files in the deploy directory to $target.md. If there are multiple markdown files present this results in an error later in the script. The actual implementation mirrors the previous one with the
head -n 1removed, to highlight its similarities to that approach.
😄 latest.md is my favorite
The implementation which supposes a markdown file latest.md will be present is my favored approach.
🌿 indicates a benefit to the current process
🌐 indicates a benefit we already have, first gained by abandoning latest
- 🌿 Minimizes the steps necessary to begin iterating on a new version of the schemas
- 🌿 Minimizes the use of variables in build scripts. Not a big deal, but I love a static value when I can use one.
- 🌐 https://spec.openapis.org/oas/3.1/schema-base/latest continues to 404
- 🌐 https://spec.openapis.org/oas/3.1/schema-base/latest.html continues to 404
- 🌐 https://spec.openapis.org/oas/3.1/schema/2024-11-14.html continues to 200
There was a problem hiding this comment.
Good discussion, please move it over to
edcd432 to
5ba8fbaCompare
ralfhandl
left a comment
There was a problem hiding this comment.
Almost there 😎
Could you extend the build-src npm script in
OpenAPI-Specification/package.json
Line 17 in 92e5fc9
to also call this script?
"build-src": "npm run validate-markdown && bash ./scripts/md2html/build.sh src && bash ./scripts/schema-publish.sh",Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| rm $target.yaml | ||
| mv $target.json $target | ||
| mv deploy/oas/$version/$base/*.md $target.md |
There was a problem hiding this comment.
Good discussion, please move it over to
Uh oh!
There was an error while loading. Please reload this page.
ralfhandl
left a comment
There was a problem hiding this comment.
Almost there. And please trust me, I've tested it on a v9.9-dev branch 😄
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
duncanbeevers
commented
Feb 24, 2025
I'm going squash this to a single commit to avoid another |
Configure deploydir based on branch name Check branch name for conformance to vX.Y.Z structure * deploy to /deploy/oas/$version if branch name is conformant * deploy to /deploy-preview if branch name is non-conformant Perform only one traversal of schemas structure Remove intermediate data structures (datesHash, sedCmd)
21c582b to
20117c7Compare
Fixes#4223
🗣️ Discussion
This PR brings the schema publishing workflow into closer alignment with the specification publishing workflow.
🔧 Under-the-hood changes
/deploy/oas/$versionif branch name is conformant/deploy-previewif branch name is non-conformantdatesHashdata structure🧑 Contributor-facing Changes
Schema publishing process works out-of-the-box on macOS
A side-effect of removing intermediate data structures is that we avoid bash-4-isms, enabling out-of-the-box builds on modern macOS versions which ship an old 3.2.57 bash version.🚗 Demo
This screenshot demonstrates running the
scripts/schema-publish.shscript from different branch names.It also includes an interrogation of a generated schema file in order to validate that all of its placeholders are replaced correctly. (Thanks @ralfhandl!)