Skip to content
Snippets Groups Projects
Verified Commit c285ff1f authored by Jonas Gröger's avatar Jonas Gröger :palm_tree:
Browse files

feat: new spec build infrastructure (planning#460)

when upstream updates swagger-cli to 4.0.5 this file needs to
be updated to remove the JonasGroeger/swagger-cli project.
parent 992a20d4
No related branches found
No related tags found
1 merge request!167BiDiKo Teil 2 - The attack (planning#460)
...@@ -21,8 +21,9 @@ build: ...@@ -21,8 +21,9 @@ build:
stage: build stage: build
image: ${CI_REGISTRY}/fit-connect/baseimage:latest image: ${CI_REGISTRY}/fit-connect/baseimage:latest
before_script: before_script:
- npm install -g @apidevtools/swagger-cli # See Makefile for as to why this is required
- mkdir dist - git clone https://github.com/JonasGroeger/swagger-cli.git /tmp/swagger-cli
- (cd /tmp/swagger-cli && npm install && npm install -g)
script: script:
- swagger-cli bundle --type yaml --outfile dist/submission-api.yaml spec/submission-api.yaml - swagger-cli bundle --type yaml --outfile dist/submission-api.yaml spec/submission-api.yaml
artifacts: artifacts:
...@@ -34,7 +35,7 @@ build: ...@@ -34,7 +35,7 @@ build:
lint: lint:
stage: lint stage: lint
image: image:
name: $CI_REGISTRY/stoplight/spectral:5 name: ${CI_REGISTRY}/stoplight/spectral:6
entrypoint: [ "" ] entrypoint: [ "" ]
script: script:
- spectral lint spec/submission-api.yaml --verbose --display-only-failures - spectral lint spec/submission-api.yaml --verbose --display-only-failures
......
...@@ -3,32 +3,30 @@ extends: ...@@ -3,32 +3,30 @@ extends:
- https://italia.github.io/api-oas-checker/spectral-generic.yml - https://italia.github.io/api-oas-checker/spectral-generic.yml
- https://italia.github.io/api-oas-checker/spectral-security.yml - https://italia.github.io/api-oas-checker/spectral-security.yml
functionsDir: './functions'
functions:
- pagination-response
rules: rules:
no-default-additionalProperties: off # Broken rules (spectral crashes) in spectral-generic.yml
string-maxlength: hint cache-responses-undocumented: off
typed-enum: error cache-control-parameter-undocumented: off
response-with-json-object: error servers-use-https: off
no-method-name-in-operationId: off
# Disabled, since we don't want a /status endpoint. # Broken rules (spectral crashes) in spectral-security.yml
# See https://git.fitko.de/fit-connect/api/-/merge_requests/37 sec-array-boundaries: off
paths-status: off sec-number-boundaries: off
paths-status-return-problem: off sec-no-additionalProperties: off
paths-status-problem-schema: off sec-no-default-additionalProperties: off
sec-constrained-additionalProperties: off
sec-securitySchemes-oauth: off
sec-securitySchemes-jwt: off
sec-string-maxlength: off
sec-string-pattern-or-format-or-enum: off
use-semver: off # Versioning is handled by CI # API_VERSION is only set during release
patch-media-type: off use-semver: warn
cache-responses-undocumented: off # Disabled, since we don't want a /status endpoint.
# See https://git.fitko.de/fit-connect/api/-/merge_requests/37
paths-status: warn
check-for-pagination: # Our PATCH endpoints are not PATCH compliant
description: An operation that returns a list and less than 4 properties could perhaps support pagination. patch-media-type: warn
message: '{{error}}'
severity: warn
given:
- $.paths.*[get]
then:
function: pagination-response
Makefile 0 → 100644
.DEFAULT_GOAL := validate-build
.PHONY: install print-version bundle validate validate-build bundle-dereferenced spectral
# The standard @apidevtools/swagger-cli does NOT install @apidevtools/swagger-parser > 10.1.0 which
# is required for OpenAPI version 3.1.0. But there is a branch from JonasGroeger that fixes that.
# Once upstream updates their dependencies (see https://github.com/APIDevTools/swagger-cli/pull/78)
# we can remove this install target and use
# npm install -g @apidevtools/swagger-cli
# again.
install:
git clone https://github.com/JonasGroeger/swagger-cli.git /tmp/swagger-cli
cd /tmp/swagger-cli && npm install && sudo npm install -g
chmod +x /tmp/swagger-cli/bin/swagger-cli.js
/tmp/swagger-cli/bin/swagger-cli.js --version
print-version:
swagger-cli --version
bundle: print-version
swagger-cli bundle \
--type yaml \
--outfile dist/submission-api.yaml \
spec/submission-api.yaml
validate: print-version
swagger-cli validate spec/submission-api.yaml
validate-build: bundle
swagger-cli validate dist/submission-api.yaml
bundle-dereferenced: print-version
swagger-cli bundle \
--type yaml \
--outfile dist/submission-api.yaml \
--dereference \
spec/submission-api.yaml
pwd := $(shell pwd)
spectral: bundle
docker run --rm --pull=always \
-v "$(pwd):/work" -w /work \
stoplight/spectral:6 lint spec/submission-api.yaml -D
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment