Wolfgang Hottgenroth 05c5c49cd5
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
dockerize goal, 6
2025-06-04 14:00:46 +02:00
2025-05-22 17:08:52 +02:00
2025-05-21 15:56:16 +02:00
2025-06-04 14:00:46 +02:00
2025-05-15 14:40:07 +02:00
2025-06-02 18:36:04 +02:00
2025-05-12 11:54:10 +02:00
2025-05-21 22:08:24 +02:00
2025-05-22 17:31:14 +02:00

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

For DefectDojo the naive code generation works.

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.

Description
No description provided
Readme 175 KiB
Languages
Python 90.5%
Shell 5.4%
Dockerfile 4.1%