You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to depend on the generated Go SDK locally (without distributing it as a separate Go module),
71
+
and you use the `module` configuration option, you will need to modify your project's top-level `go.mod` to include a [`replace`](https://go.dev/doc/modules/gomod-ref#replace) statement:
<Info>You must update the `<YOUR_ORGANIZATION>` and `<YOUR_REPOSITORY>` placeholders
107
+
with the relevant elements in your `go.mod` path. In this case, the generated Go SDK uses the same `go.mod` path used by the rest of your Go module.</Info>
By default, it's impossible to send an explicit JSON `null` for optional parameters. `enableExplicitNull: true` opts in to generating a generic `Optional[T]` type that can be used to distinguish between a `nil` value (nothing is sent), a non-`nil` value (the value is sent), and an explicit null (a `null` value is sent). This is particularly useful for `PATCH` endpoints.
122
+
123
+
The `Optional` and `Null` constructor functions will be included at the root of your module and can be
124
+
used like so:
125
+
126
+
```go
127
+
client := acmeclient.NewClient()
128
+
updatedFoo, err := client.Foo.Update(
129
+
context.TODO(),
130
+
&acme.UpdateFooRequest{
131
+
Name: acme.Optional("example"),
132
+
Tag: acme.Null[string](),
133
+
},
134
+
// Serialized as {"name":"example","tag":null}
135
+
)
136
+
```
137
+
138
+
An example configuration:
139
+
140
+
```yaml {7-8}
141
+
default-group: local
142
+
groups:
143
+
local:
144
+
generators:
145
+
- name: fernapi/fern-go-sdk
146
+
version: 0.13.0
147
+
config:
148
+
enableExplicitNull: true
149
+
output:
150
+
location: local-file-system
151
+
path: ../generated/go
152
+
```
153
+
154
+
<Note>This feature requires generics, so the generated `go.mod` will be upgraded to `1.18` (as opposed to `1.13`).</Note>
0 commit comments