Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.

Commit fe1a8ef

Browse files
authored
OpenAPI pre-processing (#32)
1 parent e63b7cf commit fe1a8ef

5 files changed

Lines changed: 29 additions & 6 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ testpub:
2525
twine upload --repository testpypi dist/*
2626

2727
schema:
28-
./support/fetch_openapi.py
28+
./support/openapi/fetch_openapi.py
2929

3030
templates:
3131
./support/api_generation/dump_templates.sh

support/api_generation/generate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
set -eo pipefail
44

5-
OPENAPI_PATH=${OPENAPI_PATH:-"support/openapi.json"}
6-
75
# make sure we're on root dir
86
cd $(dirname $0)
97
cd ..
108
cd ..
119

10+
./support/openapi/tweak_openapi.py
11+
1212
./support/api_generation/openapi-generator-cli.sh \
1313
generate \
14-
-i "${OPENAPI_PATH}" \
14+
-i support/openapi/build/openapi.json \
1515
-c support/api_generation/config.yaml \
1616
-o .
1717

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
DEMO_HOST = 'https://demo.defectdojo.org'
1111
FILE = Path(__file__).parent / 'openapi.json'
12+
SCRIPTS = Path(__file__).parent.parent / 'integration'
1213

1314

1415
def main():
@@ -18,7 +19,7 @@ def main():
1819
if args.demo:
1920
host = DEMO_HOST
2021
else:
21-
subprocess.check_call([Path(__file__).parent / 'integration' / 'run_dojo.sh'])
22+
subprocess.check_call([SCRIPTS / 'run_dojo.sh'])
2223
host = 'http://localhost:8080'
2324

2425
try:
@@ -28,7 +29,7 @@ def main():
2829
json.dump(r.json(), f, indent=4)
2930
finally:
3031
if not args.demo:
31-
subprocess.check_call([Path(__file__).parent / 'integration' / 'stop_dojo.sh'])
32+
subprocess.check_call([SCRIPTS / 'stop_dojo.sh'])
3233

3334

3435
if __name__ == '__main__':

support/openapi/tweak_openapi.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
from pathlib import Path
5+
6+
FILE = Path(__file__).parent / 'openapi.json'
7+
BUILD = Path(__file__).parent / 'build' / 'openapi.json'
8+
9+
10+
def main():
11+
BUILD.parent.mkdir(exist_ok=True)
12+
with FILE.open('r') as inp:
13+
data = json.load(inp)
14+
15+
# nothing done for now...
16+
17+
with BUILD.open('w') as out:
18+
json.dump(data, out, indent=4)
19+
20+
21+
if __name__ == '__main__':
22+
main()

0 commit comments

Comments
 (0)