initial
This commit is contained in:
95
readme.md
Normal file
95
readme.md
Normal file
@ -0,0 +1,95 @@
|
||||
# Python Client Packages for the DependencyTrack and DefectDojo API
|
||||
|
||||
## Download the OpenAPI definitions
|
||||
|
||||
```
|
||||
curl https://dtrack-api.hottis.de/api/openapi.json \
|
||||
> dependencytrack-openapi.json
|
||||
curl https://defectdojo.hottis.de/api/v2/oa3/schema/?format=json \
|
||||
> defectdojo-openapi.json
|
||||
```
|
||||
|
||||
|
||||
## Naive Generation of the Client Package for DefectDojo
|
||||
|
||||
```
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
-v $PWD:/work \
|
||||
-u $UID \
|
||||
openapitools/openapi-generator-cli:v7.12.0 \
|
||||
generate \
|
||||
-i /work/defectdojo-openapi.json \
|
||||
-g python \
|
||||
-o /work/defectdojo-client \
|
||||
--package-name defectdojo_api
|
||||
```
|
||||
|
||||
## Naive Generation of the Client Package for DependencyTrack
|
||||
|
||||
```
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
-v $PWD:/work \
|
||||
-u $UID openapitools/openapi-generator-cli:v7.12.0 \
|
||||
generate \
|
||||
-i /work/dependencytrack-openapi.json \
|
||||
-g python \
|
||||
-o /work/dependencytrack-client \
|
||||
--package-name dependencytrack_api
|
||||
```
|
||||
|
||||
## Fixed Generation of the Client Package for DependencyTrack
|
||||
|
||||
In the OpenAPI definition of DependencyTrack a regex is used which is not understood by Python's
|
||||
default regex implement `re`, which in turn is hardwired in the openapi-generator provided code.
|
||||
So, it is necessary to adjust the template for code generation to use the extended regex module
|
||||
`regex` instead of the default one.
|
||||
|
||||
For this purpose, the template must be exported:
|
||||
|
||||
```
|
||||
docker run \
|
||||
--rm \
|
||||
-v $PWD:/work \
|
||||
openapitools/openapi-generator-cli:v7.12.0 \
|
||||
author \
|
||||
template \
|
||||
-g python \
|
||||
-o /work/dependencytrack-custom-templates
|
||||
```
|
||||
|
||||
Now within `dependencytrack-custom-templates` the both files `model_anyof.mustache` and `model_generic.mustache` must be fixed.
|
||||
Replace
|
||||
|
||||
```
|
||||
import re
|
||||
```
|
||||
|
||||
at the tops of the files by
|
||||
|
||||
```
|
||||
import regex as re
|
||||
```
|
||||
|
||||
Now run the generator using the adjusted template:
|
||||
|
||||
```
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
-v $PWD:/work \
|
||||
-u $UID \
|
||||
openapitools/openapi-generator-cli:v7.12.0 \
|
||||
generate \
|
||||
-i /work/dependencytrack-openapi.json \
|
||||
-g python \
|
||||
-o /work/dependencytrack-client \
|
||||
--package-name dependencytrack_api \
|
||||
-t /work/dependencytrack-custom-templates
|
||||
```
|
||||
|
||||
Make sure to install the module `regex` in the environment the client shall run in.
|
||||
|
Reference in New Issue
Block a user