Skip to content
Snippets Groups Projects
Makefile 2.06 KiB
Newer Older
.DEFAULT_GOAL := validate
pwd := $(shell pwd)
.PHONY: bundle
	npx @redocly/cli@^1.10.6 bundle \
		--output dist/submission-api.yaml spec/submission-api.yaml
.PHONY: validate
	npx @redocly/cli@^1.10.6 lint spec/submission-api.yaml
.PHONY: validate-build
validate-build: bundle
	npx @redocly/cli@^1.10.6 lint dist/submission-api.yaml
.PHONY: bundle-dereferenced
	npx @redocly/cli@^1.10.6 bundle \
		--dereferenced --output dist/submission-api.yaml spec/submission-api.yaml
.PHONY: backup
backup:
	if [ -f dist/submission-api.yaml ]; then cp dist/submission-api.yaml dist/submission-api-before.yaml; fi

.PHONY: download-linting-rules
download-linting-rules:
	rm -r "./spectral-rules/functions" || true
	rm -r "./spectral-rules/rulesets" || true
	curl -s -L --fail-with-body --output "./spectral-rules/spectral-generic.yml" "https://github.com/italia/api-oas-checker-rules/releases/latest/download/spectral-generic.yml"
	curl -s -L --fail-with-body --output "./spectral-rules/spectral-security.yml" "https://github.com/italia/api-oas-checker-rules/releases/latest/download/spectral-security.yml"
	curl -s -L --fail-with-body --output "./spectral-rules/functions.zip" "https://github.com/italia/api-oas-checker-rules/releases/latest/download/functions.zip"
	unzip "./spectral-rules/functions.zip" -d "./spectral-rules/"
	mv "./spectral-rules/rulesets/functions" "./spectral-rules"

.PHONY: spectral
spectral: bundle download-linting-rules
	docker run --rm --pull=always \
		-v "$(pwd):/work" -w /work \
		stoplight/spectral:6.11.1  lint spec/submission-api.yaml -D --verbose # v6.13.1 breaks spectral 

# oasdiff installation: curl -fsSL https://raw.githubusercontent.com/tufin/oasdiff/main/install.sh | sh

.PHONY: oasdiff-breaking
oasdiff-breaking: bundle
	oasdiff breaking https://schema.fitko.de/fit-connect/submission-api/latest/submission-api.yaml ./dist/submission-api.yaml

.PHONY: oasdiff-changelog
oasdiff-changelog: bundle
	oasdiff changelog https://schema.fitko.de/fit-connect/submission-api/latest/submission-api.yaml dist/submission-api.yaml