Go client for the OpenProject API v3, auto-generated from the official OpenAPI spec using oapi-codegen.
go get github.com/pinealctx/openproject@latestpackage main
import (
"context"
"fmt"
"log"
"net/http"
op "github.com/pinealctx/openproject"
)
func main() {
client, err := op.NewClientWithResponses(
"https://your-instance.openproject.org/api/v3",
op.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
req.SetBasicAuth("apikey", "YOUR_API_KEY")
return nil
}),
)
if err != nil {
log.Fatal(err)
}
resp, err := client.ListProjectsWithResponse(context.Background(), &op.ListProjectsParams{})
if err != nil {
log.Fatal(err)
}
if resp.JSON200 != nil {
fmt.Printf("Total projects: %d\n", *resp.JSON200.Total)
}
}| File | Content |
|---|---|
types.gen.go |
325 Go types generated from 173 OpenAPI component schemas |
client.gen.go |
Client (raw *http.Response) and ClientWithResponses (auto-parsed) with 322 methods covering all 193 API endpoints |
spec.json |
Official OpenProject API v3 OpenAPI 3.1 spec |
downgrade_spec.py |
Script to downgrade spec from 3.1 to 3.0.3 for oapi-codegen compatibility |
Prerequisites: oapi-codegen v2, Python 3.
# Update spec.json from OpenProject, then:
make generateThe downgrade_spec.py script handles OpenAPI 3.1 → 3.0.3 conversion (type arrays → nullable, exclusiveMinimum number → boolean, allOf metadata flattening). All transformations are semantically equivalent.
MIT