Skip to content

Instantly share code, notes, and snippets.

@freshteapot
Last active October 9, 2023 10:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save freshteapot/3637e8d2b5ecdf01b7d252468eaaa45b to your computer and use it in GitHub Desktop.
Build one large openapi document from subsets, ie different api endpoints or domain logic.
generate-openapi-one:
	rm -rf /tmp/openapi/one && \
	mkdir -p /tmp/openapi/one && \
	cp ./openapi/learnalist.yaml /tmp/openapi/one/ && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.version.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.asset.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.plank.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.user.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.alist.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.spaced_repetition.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.challenge.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.mobile.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.remind.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.app_settings.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.payment.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.list_slideshow.yaml && \
	docker run --rm \
	-v "/tmp/openapi/:/src/openapi/" \
	openapitools/openapi-generator-cli generate \
		-i /src/openapi/one/learnalist.yaml \
		-g openapi-yaml \
		-o /src/openapi/one

./openapi/learnalist.yaml

  • Contains some of the base information, ie server and security setup.

Using an older yq

  • yq version 3.4.1 (Worth noting, the example uses an out of date yq, so a few modifictaions might be needed)

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment