Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Lint with spectral
run: npm install && npm run spectral
- name: Build with Maven
run: mvn clean verify --file pom.xml
4 changes: 3 additions & 1 deletion .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .spectral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extends: spectral:oas
functions: [x-header-parameter]
rules:
wrong-version:
description: OpenApi version must be 3.0.1
given: $.openapi
severity: error
then:
field: "@value"
function: pattern
functionOptions:
match: "^3.0.1+$"
Comment thread
schlijo marked this conversation as resolved.
Outdated
x-header-not-set:
message: "{{error}}"
given: $.paths.*.post
severity: error
then:
function: "x-header-parameter"
functionOptions:
value: "test"
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,22 @@ Note: _(One must have issued `npm install` previously.)_
Run e.g. on master: `mvn -B release:prepare` e.g. via [![Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/baloise/corellia)

Subsequently the GitHub action worksflow "create release" will pick up the published tag and release and deploy the artifacts in the Github package registry.


## Spectral linting (just to not forget how to do it.)

use the following comand to lint openapi.json
```
node_modules\.bin\spectral.cmd lint docs\openapi.json
Comment thread
schlijo marked this conversation as resolved.
Outdated
```
.spectral contains the rules and functions/ contains the custome functions used in the rule
Comment thread
schlijo marked this conversation as resolved.
Outdated
Custom example rules are:
- Version must be 3.0.1
- all post actions must have X-Caller-Name and X-EventId in the header

All standard rules for openapie 3 are usesd as well.

Documentation can be found here:
https://meta.stoplight.io/docs/spectral/README.md

docker run --rm -it -v %cd%:/tmp quay.balgroupit.com/baloise-base-images/spectral lint /tmp/docs/openapi.json --ruleset=/tmp/docs/spectral.yaml
Comment thread
schlijo marked this conversation as resolved.
Outdated
10 changes: 10 additions & 0 deletions functions/x-header-parameter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = (targetVal, opts) => {
headers = targetVal.parameters.filter(param => (param.name == "X-Caller-Name" || param.name == "X-Event-ID"));
Comment thread
schlijo marked this conversation as resolved.
Outdated
if (headers.length != 2) {
return [
{
message: 'Header must have X-Caller-Name and X-Event-Id set in operation: ' + targetVal.operationId,
},
];
}
};
Loading