Commit 70bd64e
fix(go): support form-urlencoded request body encoding (#11426)
* fix(go): support form-urlencoded request body encoding
OAuth token requests and other endpoints with `application/x-www-form-urlencoded`
content type were failing because the Go SDK always serialized request bodies as
JSON, regardless of the Content-Type header.
This fix modifies the internal caller to:
- Detect form-urlencoded content type from endpoint headers
- Use `url.Values.Encode()` for form-urlencoded requests instead of JSON marshaling
- Properly handle struct fields using json tags for field names
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* feat(go): add wire tests for OAuth client credentials fixture
- Add OAuthWireTestGenerator to generate OAuth-specific wire tests
- Enable wire tests for oauth-client-credentials fixture in seed.yml
- Add content-type: application/x-www-form-urlencoded to OAuth token endpoints
- Tests validate form URL encoded body encoding and custom header propagation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* fix(go): make OAuth wire tests dynamic to support different SDK structures
The OAuth wire test generator now dynamically extracts service structure
from the IR instead of hardcoding assumptions. This allows the tests to
work with different OAuth configurations:
- Service accessor path (e.g., OAuth2 vs Auth)
- Method name (e.g., GetToken vs GetTokenWithClientCredentials)
- Field names (e.g., ClientID vs ClientId)
- Field types (optional pointer vs required string)
- Test file location based on actual service package
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Update version
* chore: update oauth-client-credentials test definition
Co-Authored-By: [email protected] <[email protected]>
* chore: remove oauth-client-credentials from seed-groups.json files
Co-Authored-By: [email protected] <[email protected]>
* refactor(go): improve OAuthWireTestGenerator to follow canonical patterns
- Use context.getClientFileLocation() instead of custom getPackageDir() logic
- Use context.getFieldName() for field names instead of custom goExportedFieldName
- Implement dynamic request type derivation matching ClientGenerator pattern
- Add helper methods for request property field names and optionality checks
Co-Authored-By: [email protected] <[email protected]>
* test(go): add unit tests for form URL encoding in caller
- Add TestNewFormURLEncodedBody for map-based form encoding
- Add TestNewFormURLEncodedRequestBody for struct-based form encoding
- Add TestNewRequestBodyFormURLEncoded for content-type selection logic
- Include tests for special characters, omitempty handling, and pointer fields
Co-Authored-By: [email protected] <[email protected]>
* Update new test and confirm tests pass in fixture
* Update go sdk output
* fix(go): use unique docker-compose project names to prevent parallel test conflicts
Co-Authored-By: [email protected] <[email protected]>
---------
Co-authored-by: jsklan <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 9a2e55e commit 70bd64e
File tree
24 files changed
+1735
-38
lines changed- .github/workflow-resource-files/seed-groups
- generators
- go-v2
- base/src/asIs/internal
- sdk/src/wire-tests
- go/sdk
- packages/cli/generation/ir-generator-tests/src/ir/__test__/test-definitions
- seed/go-sdk
- oauth-client-credentials
- .fern
- auth
- auth_test
- oauth_wire_test
- internal
- nestednoauth
- api/nested_no_auth_api_test
- nested
- api/nested_api_test
- simple/simple_test
- wiremock
- url-form-encoded/internal
- test-definitions/fern/apis/oauth-client-credentials/definition
24 files changed
+1735
-38
lines changedLines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
183 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
| |||
189 | 197 | | |
190 | 198 | | |
191 | 199 | | |
192 | | - | |
| 200 | + | |
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
198 | 206 | | |
199 | 207 | | |
200 | | - | |
| 208 | + | |
201 | 209 | | |
202 | 210 | | |
203 | 211 | | |
204 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
205 | 216 | | |
206 | 217 | | |
207 | 218 | | |
| |||
211 | 222 | | |
212 | 223 | | |
213 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
214 | 229 | | |
215 | 230 | | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
219 | 234 | | |
220 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
221 | 301 | | |
222 | 302 | | |
223 | 303 | | |
| |||
0 commit comments