Go SDK for the Shiper API.
package main
import (
"context"
"log"
shiper "github.com/shiper-app/shiper-go"
)
func main() {
client, err := shiper.NewClient(shiper.WithToken("YOUR_TOKEN"))
if err != nil {
log.Fatal(err)
}
resp, err := client.ListProjects(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
log.Printf("projects: %d", len(resp.JSON200.Data))
envs, err := client.ListEnvironments(context.Background(), "project-id")
if err != nil {
log.Fatal(err)
}
log.Printf("environments: %d", len(envs.JSON200.Environments))
}- Regenerate
internal/genapi/client.gen.go(go generate ./...). - Add a thin
*Clientmethod in the matching resource file (projects.go,users.go,variables.go,environments.go). - Follow wrapper rules: validate required IDs, call
raw.<Endpoint>WithResponse, enforce status withrequireStatus/require2xx, returnnewAPIErroron unexpected status. - Add aliases in
types.goif new request/response types are needed. - Add/extend a focused test for success and non-2xx behavior.
- Download
api-1.jsonfrom https://api.shiper.app/v2. - Down-convert to OpenAPI 3.0:
npx @apiture/openapi-down-convert --input api-1.json --output spec-3.0.yaml. - Patch the spec for oapi-codegen compatibility (collapses
anyOf: [X, null]intonullable: trueand setstype: stringon bare string enums):node hack/fix-nullables.mjs spec-3.0.yaml. Runcd hack && npm installonce to fetch the YAML dep. - Regenerate the client:
go generate ./.... - Commit the generated code and any handwritten wrapper changes and push to main.
- Create a new release with the tag name
vX.Y.Zwhere X.Y.Z is the new version number.