-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Implement GitHub Actions workflow for automatically updating the example JSON files #2068
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
Conversation
webron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, this is awesome. Would it make sense to change the Action to run on *.yaml in that directory instead?
.github/workflows/yaml2json.yml
Outdated
| push: | ||
| branches: | ||
| - master | ||
| - try-github-actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that still needed? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not, going to remove that before merging this PR. But it will run the action if I make adjustments to this branch so I'd keep it for testing until it is ready to merge.
what do you mean? As far as I am aware there is no way to run an action based on whether some files changed or not. |
|
@webron is there anything to change or to do from my side to get this merged? (except from removing the |
|
Sorry, I didn't mean run it based on whether a file changed, but rather here: instead of running it on each file individually, it'd be more robust if it ran on all yaml file in the directory, in case additional files are added. |
|
Also, what indentation is used in the output json? I guess it should match the v2.0 examples for consistency. |
|
Indentation is currently 4 spaces, I'll change that to 2. |
|
yes, symfony/yaml has some problems with these files, did not see that PR, will try to merge the commit and see if it fixes the problem.
sure I can do that. |
This workflow updates the *.json files in the examples/v3.0 directory, when the corresponding *.yaml files change. JSON example files are automatically generated from the YAML example files. Only the YAML files should be adjusted manually. fixes OAI#1385 - When a push to `master` (or any other branch we wish to include) is made, a Github Actions Workflow is triggered ([example](https://github.com/cebe/OpenAPI-Specification/commit/9c98e819ae876af92c2a9112dcfa6dfcb929e7dc/checks?check_suite_id=331067708)) - it will generate new JSON files from the YAML examples - if there are any changes, it will create a pull request to the branch that triggered the Workflow ([example](#3))
1572979 to
22c0653
Compare
close OAI#2036
4db07c7 to
2d1e210
Compare
|
Merged the changes from #2036, they fix the issue with api-with-examples.yaml.
done.
indentation is 2 now. Ready to merge from my side. |
2d1e210 to
d1ed602
Compare
webron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with the changes. @MikeRalphson please verify as well. If It's all good, we need to remove the test branch from the script and then merge it.
|
My only question is why we indent the target with tabs and then (presumably) overwrite it with a space indented version. Otherwise LGTM. |
The tool I use for indentation can not convert 4 space to 2 space indentation. it can only convert tabs to spaces or spaces to tabs. So I do the conversion in two steps, 4 spaces to tabs, then tabs to 2 spaces. |
done. |
|
@webron are you ok to create the |
|
@MikeRalphson If I understand correctly, |
|
👍 |
|
there is no need to add a github token manually, it is provided by Github actions. Anything stopping this from being merged? |
|
Closing this, as #2199 is replacing it. |
As discussed in #1385 the example
.jsonfiles for version 3 should be automatically generated from the.yamlexample files.I thought this was a good case for trying out Github Actions and the result is the following:
master(or any other branch we wish to include) is made, a Github Actions Workflow is triggered (example)