DefectDojo API client in Go
This client is generated automatically from the DefectDojo OpenAPI 3.0 spec, using github.com/deepmap/oapi-codegen. So it has some quirks.
API Documentation: https://pkg.go.dev/github.com/doximity/defect-dojo-client-go
Import the module:
import (
dd "github.com/doximity/defect-dojo-client-go"
"github.com/deepmap/oapi-codegen/pkg/securityprovider"
)
Create a client:
url := "https://demo.defectdojo.org"
token := os.Getenv("DOJO_APIKEY")
tokenProvider, err := securityprovider.NewSecurityProviderApiKey("header", "Authorization", fmt.Sprintf("Token %s", token))
if err != nil {
panic(err)
}
client, err := dd.NewClientWithResponses(url, dd.WithRequestEditorFn(tokenProvider.Intercept))
Make a request (in this case create a product, i.e. POST /products/
):
apiResp, err := client.ProductsCreateWithResponse(ctx, dd.ProductsCreateJSONRequestBody{
Name: "My Product",
Description: "A description",
ProdType: 1,
})
Access fields from the response:
if apiResp.StatusCode() == 201 {
createdProductId := apiResp.JSON201.Id
//...
}
To build the client, run:
$ oapi-codegen Defect-Dojo-API-v2.x.x.json > defectdojo.gen.go
Pull requests are welcome. By contributing to this repository you are agreeing to the Contributor License Agreement (CONTRIBUTING.md)
Licensed under the Apache v2 license. See LICENSE.txt