Skip to content

Commit 7ba0438

Browse files
release: 0.4.0 (#16)
* chore: bump go sdk version * fix(client): improve docs * fix: update request schema for Postman webhook * fix(client)!: improve union variant names * feat(api): enable macos publishing * fix(client)!: improve core function names * feat(client)!: rename resp package * chore(docs): update respjson package name * fix(client): correctly update body in WithJSONSet * fix(client): unmarshal responses properly * fix(client): include path for type names in example code * fix(client): clean up reader resources * feat(client): experimental support for unmarshalling into param structs * feat(api): add build compare to v0 * release: 0.4.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 39ab252 commit 7ba0438

36 files changed

+1779
-724
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.3.0"
2+
".": "0.4.0"
33
}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-5005d23980f589ea52eb1678ed620336b7c1172e3b1493a5c819c6b00f22203e.yml
3-
openapi_spec_hash: 2a29f55c69490ab4d0ee5eb32727ab46
4-
config_hash: 66be21d9e622533a4b22a18501a02005
1+
configured_endpoints: 15
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-6707704fb4cbc87d367d0813979036b8acbcc7f6eff62f7f5e8b9f016920d3ad.yml
3+
openapi_spec_hash: 3af7623ae449e42f72c7319fa3f8e387
4+
config_hash: 47554631761ae001c9bf76a4fb4ba43a

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# Changelog
22

3+
## 0.4.0 (2025-05-13)
4+
5+
Full Changelog: [v0.3.0...v0.4.0](https://github.com/stainless-api/stainless-api-go/compare/v0.3.0...v0.4.0)
6+
7+
### ⚠ BREAKING CHANGES
8+
9+
* **client:** rename resp package
10+
* **client:** improve core function names
11+
* **client:** improve union variant names
12+
13+
### Features
14+
15+
* **api:** add build compare to v0 ([b74be33](https://github.com/stainless-api/stainless-api-go/commit/b74be333a6635561427ad62806d892a161aad6c3))
16+
* **api:** enable macos publishing ([dfd46df](https://github.com/stainless-api/stainless-api-go/commit/dfd46df667ed6f23d4eb602df2db236326da23bc))
17+
* **client:** experimental support for unmarshalling into param structs ([304a75b](https://github.com/stainless-api/stainless-api-go/commit/304a75b5b6ea718fdd45f829bfa96d7f611b1e43))
18+
* **client:** rename resp package ([d554f47](https://github.com/stainless-api/stainless-api-go/commit/d554f478582782eb50b2305d8d1233c2908b07c2))
19+
20+
21+
### Bug Fixes
22+
23+
* **client:** clean up reader resources ([69e116e](https://github.com/stainless-api/stainless-api-go/commit/69e116e4e92e5906258971e6394e2b0869663135))
24+
* **client:** correctly update body in WithJSONSet ([fed7230](https://github.com/stainless-api/stainless-api-go/commit/fed72307ffa68a02c7e8241c0841d19f6f46c63a))
25+
* **client:** improve core function names ([6a55bff](https://github.com/stainless-api/stainless-api-go/commit/6a55bff84360c6b5f45261d621fd3a7c0b55a2b4))
26+
* **client:** improve docs ([e0221f2](https://github.com/stainless-api/stainless-api-go/commit/e0221f2fa6ff755f2b71d3f5f3920999b205e107))
27+
* **client:** improve union variant names ([e555b82](https://github.com/stainless-api/stainless-api-go/commit/e555b826254cde0408443d1cb0a48b693638c060))
28+
* **client:** include path for type names in example code ([e36155b](https://github.com/stainless-api/stainless-api-go/commit/e36155b7dbd43f6ed920943aa9f208a2b0de0854))
29+
* **client:** unmarshal responses properly ([4894832](https://github.com/stainless-api/stainless-api-go/commit/489483217aa805f4a093c9492a5dff2b3a305480))
30+
* update request schema for Postman webhook ([49e4069](https://github.com/stainless-api/stainless-api-go/commit/49e406984f4915919f9c921aeb27c74d6ab5c6e1))
31+
32+
33+
### Chores
34+
35+
* bump go sdk version ([bbb906c](https://github.com/stainless-api/stainless-api-go/commit/bbb906cea4dd3065a0fe32f74e15f0f9187144ce))
36+
* **docs:** update respjson package name ([2054dd0](https://github.com/stainless-api/stainless-api-go/commit/2054dd0c41817c5a29068cf5992f48941b5d4626))
37+
338
## 0.3.0 (2025-04-30)
439

540
Full Changelog: [v0.2.0...v0.3.0](https://github.com/stainless-api/stainless-api-go/compare/v0.2.0...v0.3.0)

README.md

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Or to pin the version:
2424
<!-- x-release-please-start-version -->
2525

2626
```sh
27-
go get -u 'github.com/stainless-api/stainless-api-go@v0.3.0'
27+
go get -u 'github.com/stainless-api/stainless-api-go@v0.4.0'
2828
```
2929

3030
<!-- x-release-please-end -->
@@ -79,8 +79,10 @@ Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be se
7979
Any `param.Opt[T]`, map, slice, struct or string enum uses the
8080
tag <code>\`json:"...,omitzero"\`</code>. Its zero value is considered omitted.
8181

82+
The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.
83+
8284
```go
83-
params := stainlessv0.ExampleParams{
85+
p := stainlessv0.ExampleParams{
8486
ID: "id_xxx", // required property
8587
Name: stainlessv0.String("..."), // optional property
8688

@@ -94,34 +96,34 @@ params := stainlessv0.ExampleParams{
9496
}
9597
```
9698

97-
To send `null` instead of a `param.Opt[T]`, use `param.NullOpt[T]()`.
98-
To send `null` instead of a struct `T`, use `param.NullObj[T]()`.
99+
To send `null` instead of a `param.Opt[T]`, use `param.Null[T]()`.
100+
To send `null` instead of a struct `T`, use `param.NullStruct[T]()`.
99101

100102
```go
101-
params.Description = param.NullOpt[string]() // explicit null string property
102-
params.Point = param.NullObj[Point]() // explicit null struct property
103+
p.Name = param.Null[string]() // 'null' instead of string
104+
p.Point = param.NullStruct[Point]() // 'null' instead of struct
105+
106+
param.IsNull(p.Name) // true
107+
param.IsNull(p.Point) // true
103108
```
104109

105-
Request structs contain a `.WithExtraFields(map[string]any)` method which can send non-conforming
110+
Request structs contain a `.SetExtraFields(map[string]any)` method which can send non-conforming
106111
fields in the request body. Extra fields overwrite any struct fields with a matching
107-
key. For security reasons, only use `WithExtraFields` with trusted data.
112+
key. For security reasons, only use `SetExtraFields` with trusted data.
108113

109-
To send a custom value instead of a struct, use `param.OverrideObj[T](value)`.
114+
To send a custom value instead of a struct, use `param.Override[T](value)`.
110115

111116
```go
112117
// In cases where the API specifies a given type,
113-
// but you want to send something else, use [WithExtraFields]:
114-
params.WithExtraFields(map[string]any{
118+
// but you want to send something else, use [SetExtraFields]:
119+
p.SetExtraFields(map[string]any{
115120
"x": 0.01, // send "x" as a float instead of int
116121
})
117122

118123
// Send a number instead of an object
119-
custom := param.OverrideObj[stainlessv0.FooParams](12)
124+
custom := param.Override[stainlessv0.FooParams](12)
120125
```
121126

122-
When available, use the `.IsPresent()` method to check if an optional parameter is not omitted or `null`.
123-
The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.
124-
125127
### Request unions
126128

127129
Unions are represented as a struct with fields prefixed by "Of" for each of it's variants,
@@ -164,38 +166,44 @@ type Animal struct {
164166
Owners int `json:"owners"`
165167
Age int `json:"age"`
166168
JSON struct {
167-
Name resp.Field
168-
Owner resp.Field
169-
Age resp.Field
170-
ExtraFields map[string]resp.Field
169+
Name respjson.Field
170+
Owner respjson.Field
171+
Age respjson.Field
172+
ExtraFields map[string]respjson.Field
171173
} `json:"-"`
172174
}
173175
```
174176

175-
To handle optional data, use the `IsPresent()` method on the JSON field.
176-
If a field is `null`, not present, or invalid, the corresponding field
177-
will simply be its zero value.
177+
To handle optional data, use the `.Valid()` method on the JSON field.
178+
`.Valid()` returns true if a field is not `null`, not present, or couldn't be marshaled.
179+
180+
If `.Valid()` is false, the corresponding field will simply be its zero value.
178181

179182
```go
180183
raw := `{"owners": 1, "name": null}`
181184

182185
var res Animal
183186
json.Unmarshal([]byte(raw), &res)
184187

185-
// Use the IsPresent() method to handle optional fields
186-
res.Owners // 1
187-
res.JSON.Owners.IsPresent() // true
188-
res.JSON.Owners.Raw() // "1"
188+
// Accessing regular fields
189+
190+
res.Owners // 1
191+
res.Name // ""
192+
res.Age // 0
193+
194+
// Optional field checks
189195

190-
res.Age // 0
191-
res.JSON.Age.IsPresent() // false
192-
res.JSON.Age.Raw() // ""
196+
res.JSON.Owners.Valid() // true
197+
res.JSON.Name.Valid() // false
198+
res.JSON.Age.Valid() // false
193199

194-
// Use the IsExplicitNull() method to differentiate null and omitted
195-
res.Name // ""
196-
res.JSON.Name.IsPresent() // false
197-
res.JSON.Name.Raw() // "null"
198-
res.JSON.Name.IsExplicitNull() // true
200+
// Raw JSON values
201+
202+
res.JSON.Owners.Raw() // "1"
203+
res.JSON.Name.Raw() == "null" // true
204+
res.JSON.Name.Raw() == respjson.Null // true
205+
res.JSON.Age.Raw() == "" // true
206+
res.JSON.Age.Raw() == respjson.Omitted // true
199207
```
200208

201209
These `.JSON` structs also include an `ExtraFields` map containing
@@ -225,8 +233,9 @@ type AnimalUnion struct {
225233
// From variant [Cat]
226234
CatBreed string `json:"cat_breed"`
227235
// ...
236+
228237
JSON struct {
229-
Owner resp.Field
238+
Owner respjson.Field
230239
// ...
231240
} `json:"-"`
232241
}

api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Response Types:
2121
Methods:
2222

2323
- <code title="post /v0/projects/{project}/branches">client.Projects.Branches.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranchService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, project <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranchNewParams">ProjectBranchNewParams</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranch">ProjectBranch</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
24-
- <code title="get /v0/projects/{project}/branches/{branch}">client.Projects.Branches.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranchService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, project <a href="https://pkg.go.dev/builtin#string">string</a>, branch <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranch">ProjectBranch</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
24+
- <code title="get /v0/projects/{project}/branches/{branch}">client.Projects.Branches.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranchService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, branch <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranchGetParams">ProjectBranchGetParams</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#ProjectBranch">ProjectBranch</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2525

2626
## Configs
2727

@@ -52,12 +52,14 @@ Response Types:
5252
- <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildObject">BuildObject</a>
5353
- <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildTarget">BuildTarget</a>
5454
- <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildListResponse">BuildListResponse</a>
55+
- <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildCompareResponse">BuildCompareResponse</a>
5556

5657
Methods:
5758

5859
- <code title="post /v0/builds">client.Builds.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildNewParams">BuildNewParams</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildObject">BuildObject</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
5960
- <code title="get /v0/builds/{buildId}">client.Builds.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, buildID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildObject">BuildObject</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
6061
- <code title="get /v0/builds">client.Builds.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildListParams">BuildListParams</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildListResponse">BuildListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
62+
- <code title="post /v0/builds/compare">client.Builds.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildService.Compare">Compare</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildCompareParams">BuildCompareParams</a>) (<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go">stainlessv0</a>.<a href="https://pkg.go.dev/github.com/stainless-api/stainless-api-go#BuildCompareResponse">BuildCompareResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
6163

6264
# BuildTargetOutputs
6365

0 commit comments

Comments
 (0)