Skip to content

Remove yaml2json #4386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025
Merged

Remove yaml2json #4386

merged 1 commit into from
Feb 28, 2025

Conversation

duncanbeevers
Copy link
Contributor

@duncanbeevers duncanbeevers commented Feb 27, 2025

🗣️ Discussion

The yaml2json script duplicates functionality already present in the yaml module / CLI.
Rather than generating and juggling tempfiles,

This PR generates the schema JSON files by piping and redirecting…
…instead of generating-then-transforming-then-deleting-then-moving

This is a nearly pure refactor with no expected behavior changes other than the addition of a trailing newline on the published schemas.

Run bash ./scripts/schema-publish.sh src to generate the schemas and inspect the output.

diff --color -r deploy-preview-dev/dialect/2024-11-10 deploy-preview/dialect/2024-11-10
25c25
< }
\ No newline at end of file
---
> }
diff --color -r deploy-preview-dev/meta/2024-11-10 deploy-preview/meta/2024-11-10
92c92
< }
\ No newline at end of file
---
> }
diff --color -r deploy-preview-dev/schema/2024-11-21 deploy-preview/schema/2024-11-21
1408c1408
< }
\ No newline at end of file
---
> }
diff --color -r deploy-preview-dev/schema-base/2024-11-21 deploy-preview/schema-base/2024-11-21
25c25
< }
\ No newline at end of file
---
> }

@duncanbeevers duncanbeevers requested review from a team as code owners February 27, 2025 21:25
rm "$target.yaml"
mv "$target.json" "$target"
# replace the WORK-IN-PROGRESS placeholders
sed ${sedCmd[@]} $schemaDir/$schema | npx yaml --json --indent 2 --single > $target
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --json flag transforms the streamed yaml to JSON.
The --indent 2 flag specifies the indentation level of the JSON
The --single flag indicates we are processing a single file and not a stream, which prevents the output from being wrapped in an extra [] pair.

@ralfhandl ralfhandl merged commit 9f113bd into OAI:dev Feb 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants