Skip to content
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

Generate 3.0 JSON examples from 3.0 YAML examples in json/yaml subfolders #1385

Closed
darrelmiller opened this issue Oct 20, 2017 · 5 comments
Closed
Labels
examples requests for more or better examples in the specification

Comments

@darrelmiller
Copy link
Member

No description provided.

@MikeRalphson
Copy link
Member

Refs #1357

@darrelmiller
Copy link
Member Author

Yes, I should have mentioned that the PR referenced inspired this decision. We don't want to add maintenance burden by having both formats, but we can generate them.

@cebe
Copy link
Contributor

cebe commented Nov 26, 2019

What kind of tooling would you accept into the repo? Is there any preference for language/toolchain to use?

With PHP installed, the following Makefile would generate JSON files from all YAML files in a directory:

YAMLS := $(wildcard ./*.yaml)
JSONS := $(patsubst ./%.yaml, ./%.json, $(YAMLS))

all: vendor/bin/php-openapi $(JSONS)

vendor/bin/php-openapi:
	echo '{}' > composer.json
	composer require cebe/php-openapi 'symfony/yaml:~4.2.0'

%.json: %.yaml
	vendor/bin/php-openapi convert --read-yaml $< --write-json $@

.PHONY: all

If PHP and GNU Make is acceptable tooling, I can send a PR with setting it up.

@SephReed
Copy link

I'd put in a request for this too. It's not like it's hard to convert on ones own, but I was just looking for some quick test data. Even just one json example would have been enough to save me the trouble of converting it myself.

https://onlineyamltools.com/convert-yaml-to-json

cebe added a commit to cebe/OpenAPI-Specification that referenced this issue Dec 6, 2019
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))
@MikeRalphson
Copy link
Member

Closing as #2199 was merged. Thanks all.

@handrews handrews added the examples requests for more or better examples in the specification label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples requests for more or better examples in the specification
Projects
None yet
Development

No branches or pull requests

5 participants