-
Notifications
You must be signed in to change notification settings - Fork 9
53 lines (47 loc) · 1.31 KB
/
custom-linter.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Custom Linter
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
push:
branches:
- dev
jobs:
# OpenAPI request bodies should contain the property `required` and be set to true
#
# // Valid (request body required)
#
# requestBody: {
# required: true,
# content: {}
# }
#
# // Invalid (request body not required)
#
# requestBody: {
# content: {}
# }
#
openApiRequiredRequestBody:
name: OpenAPI requestBody missing required:true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find schemas with optional request bodies
run: |
# For OpenAPI schemas, find all request bodies that don't have `required:true`
#
# Find all non-test files in apr/src/paths
# Find all request bodies that don't contain required:true property
# Print to stdout line num + filename and return exit code
find api/src/paths -type f ! -name '*.test.ts' -exec \
awk '
BEGIN {found=0}
/requestBody:/ {found=1}
/required: true/ {found=0}
/content:/ {
if (found) print "line: " NR, FILENAME;
found=0;
}
' {} \; \
| grep . && exit 1 || exit 0