diff --git a/package-lock.json b/package-lock.json index a45a40e3..c53b5904 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "@seamapi/blueprint", - "version": "0.28.1", + "version": "0.28.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@seamapi/blueprint", - "version": "0.28.1", + "version": "0.28.2", "license": "MIT", "dependencies": { "change-case": "^5.4.4", "zod": "^3.23.8" }, "devDependencies": { - "@seamapi/types": "1.262.1", + "@seamapi/types": "1.264.2", "@types/node": "^20.8.10", "ava": "^6.0.1", "c8": "^10.1.2", @@ -1052,9 +1052,9 @@ ] }, "node_modules/@seamapi/types": { - "version": "1.262.1", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.262.1.tgz", - "integrity": "sha512-AlwwSnSFQNeTB1rGYqtztJII9vieEbcmaLuFtK1PokFQSan+u/B5esuh1ZPPfRSGP7QWNThpBdvuP0z6vAii4Q==", + "version": "1.264.2", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.264.2.tgz", + "integrity": "sha512-PJzQEN1TVmJ9rCIbgC/0R6iG0uc+/vlHzspknnxF5O5QzuH/pv+YN0vRFkF9WxTMo99lDjIPr6myEnlvAsX1WQ==", "dev": true, "engines": { "node": ">=18.12.0", diff --git a/package.json b/package.json index 20e34982..f2036e3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seamapi/blueprint", - "version": "0.28.1", + "version": "0.28.2", "description": "Build tools for the Seam API using this blueprint.", "type": "module", "main": "index.js", @@ -73,7 +73,7 @@ "zod": "^3.23.8" }, "devDependencies": { - "@seamapi/types": "1.262.1", + "@seamapi/types": "1.264.2", "@types/node": "^20.8.10", "ava": "^6.0.1", "c8": "^10.1.2", diff --git a/src/lib/code-sample/go.ts b/src/lib/code-sample/go.ts index 6d731be9..94456f51 100644 --- a/src/lib/code-sample/go.ts +++ b/src/lib/code-sample/go.ts @@ -24,7 +24,7 @@ export const createGoRequest = ( goPackageName, requestStructName, }) - const goSdkRequestArgs = `context.Background()${isReqWithParams ? `, ${goPackageName}.${requestStructName}{${formattedArgs}}` : ''}` + const goSdkRequestArgs = `context.Background()${isReqWithParams ? `,\n${goPackageName}.${requestStructName}{\n${formattedArgs},\n}` : ''}` const pathParts = request.path.split('/') @@ -32,7 +32,7 @@ export const createGoRequest = ( ${goSdkImports} func main() { - client${pathParts.map((p) => pascalCase(p)).join('.')}(${goSdkRequestArgs}) + client${pathParts.map((p) => pascalCase(p)).join('.')}(${isReqWithParams ? '\n' : ''}${goSdkRequestArgs},\n) } `.trim() } @@ -105,7 +105,7 @@ const formatGoRequestArgs = ( ) return `${pascalCase(paramKey)}: ${formattedValue}` }) - .join(', ') + .join(',\n') const formatGoRequestArgValue = ( key: string, diff --git a/test/snapshots/blueprint.test.ts.md b/test/snapshots/blueprint.test.ts.md index bf7d1575..f0211eda 100644 --- a/test/snapshots/blueprint.test.ts.md +++ b/test/snapshots/blueprint.test.ts.md @@ -272,7 +272,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.Get(context.Background(), api.FoosGetRequest{FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33")})␊ + client.Foos.Get(␊ + context.Background(),␊ + api.FoosGetRequest{␊ + FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33"),␊ + },␊ + )␊ }`, request_syntax: 'go', response: 'api.Foo{FooId: "8d7e0b3a-b889-49a7-9164-4b71a0506a33", Name: "Best foo", NullableProp: nil, NumberProp: 10, ObjectProp: api.FooObjectProp{Foo: "bar", NestedObjectProp: api.FooObjectPropNestedObjectProp{Foo: "bar"}}, ArrayProp: []string{"foo", "bar"}}', @@ -395,7 +400,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.List(context.Background(), api.FoosListRequest{ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")}})␊ + client.Foos.List(␊ + context.Background(),␊ + api.FoosListRequest{␊ + ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")},␊ + },␊ + )␊ }`, request_syntax: 'go', response: '[]api.Foo{api.Foo{FooId: "8d7e0b3a-b889-49a7-9164-4b71a0506a33", Name: "Best foo", NullableProp: nil, NumberProp: 10, ObjectProp: api.FooObjectProp{Foo: "bar"}, ArrayProp: []string{"foo", "bar"}}}', @@ -519,7 +529,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.Get(context.Background(), api.FoosGetRequest{FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33")})␊ + client.Foos.Get(␊ + context.Background(),␊ + api.FoosGetRequest{␊ + FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33"),␊ + },␊ + )␊ }`, request_syntax: 'go', response: 'api.Foo{FooId: "8d7e0b3a-b889-49a7-9164-4b71a0506a33", Name: "Best foo", NullableProp: nil, NumberProp: 10, ObjectProp: api.FooObjectProp{Foo: "bar", NestedObjectProp: api.FooObjectPropNestedObjectProp{Foo: "bar"}}, ArrayProp: []string{"foo", "bar"}}', @@ -642,7 +657,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.List(context.Background(), api.FoosListRequest{ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")}})␊ + client.Foos.List(␊ + context.Background(),␊ + api.FoosListRequest{␊ + ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")},␊ + },␊ + )␊ }`, request_syntax: 'go', response: '[]api.Foo{api.Foo{FooId: "8d7e0b3a-b889-49a7-9164-4b71a0506a33", Name: "Best foo", NullableProp: nil, NumberProp: 10, ObjectProp: api.FooObjectProp{Foo: "bar"}, ArrayProp: []string{"foo", "bar"}}}', @@ -766,7 +786,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.Get(context.Background(), api.FoosGetRequest{FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33")})␊ + client.Foos.Get(␊ + context.Background(),␊ + api.FoosGetRequest{␊ + FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33"),␊ + },␊ + )␊ }`, request_syntax: 'go', response: 'api.Foo{FooId: "8d7e0b3a-b889-49a7-9164-4b71a0506a33", Name: "Best foo", NullableProp: nil, NumberProp: 10, ObjectProp: api.FooObjectProp{Foo: "bar", NestedObjectProp: api.FooObjectPropNestedObjectProp{Foo: "bar"}}, ArrayProp: []string{"foo", "bar"}}', @@ -889,7 +914,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.List(context.Background(), api.FoosListRequest{ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")}})␊ + client.Foos.List(␊ + context.Background(),␊ + api.FoosListRequest{␊ + ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")},␊ + },␊ + )␊ }`, request_syntax: 'go', response: '[]api.Foo{api.Foo{FooId: "8d7e0b3a-b889-49a7-9164-4b71a0506a33", Name: "Best foo", NullableProp: nil, NumberProp: 10, ObjectProp: api.FooObjectProp{Foo: "bar"}, ArrayProp: []string{"foo", "bar"}}}', @@ -1024,7 +1054,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Transport.Air.Planes.List(context.Background())␊ + client.Transport.Air.Planes.List(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: '[]api.Plane{api.Plane{PlaneId: "9d3163f9-9185-40d3-a0ce-a03d3c7ce402", Name: "Woosh"}}', @@ -1134,7 +1165,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Transport.Air.Planes.List(context.Background())␊ + client.Transport.Air.Planes.List(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: '[]api.Plane{api.Plane{PlaneId: "9d3163f9-9185-40d3-a0ce-a03d3c7ce402", Name: "Woosh"}}', @@ -1244,7 +1276,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Transport.Air.Planes.List(context.Background())␊ + client.Transport.Air.Planes.List(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: '[]api.Plane{api.Plane{PlaneId: "9d3163f9-9185-40d3-a0ce-a03d3c7ce402", Name: "Woosh"}}', @@ -1370,7 +1403,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Deprecated.Undocumented.Endpoint(context.Background())␊ + client.Deprecated.Undocumented.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: 'nil', @@ -1471,7 +1505,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Deprecated.Undocumented.Endpoint(context.Background())␊ + client.Deprecated.Undocumented.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: 'nil', @@ -1572,7 +1607,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Deprecated.Undocumented.Endpoint(context.Background())␊ + client.Deprecated.Undocumented.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: 'nil', @@ -1689,7 +1725,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Draft.Endpoint(context.Background())␊ + client.Draft.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: 'nil', @@ -1790,7 +1827,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Draft.Endpoint(context.Background())␊ + client.Draft.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: 'nil', @@ -1891,7 +1929,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Draft.Endpoint(context.Background())␊ + client.Draft.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: 'nil', @@ -2260,7 +2299,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.Get(context.Background(), api.FoosGetRequest{FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33")})␊ + client.Foos.Get(␊ + context.Background(),␊ + api.FoosGetRequest{␊ + FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33"),␊ + },␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -2399,7 +2443,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.List(context.Background(), api.FoosListRequest{ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")}})␊ + client.Foos.List(␊ + context.Background(),␊ + api.FoosListRequest{␊ + ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")},␊ + },␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -2539,7 +2588,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.Get(context.Background(), api.FoosGetRequest{FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33")})␊ + client.Foos.Get(␊ + context.Background(),␊ + api.FoosGetRequest{␊ + FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33"),␊ + },␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -2678,7 +2732,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.List(context.Background(), api.FoosListRequest{ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")}})␊ + client.Foos.List(␊ + context.Background(),␊ + api.FoosListRequest{␊ + ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")},␊ + },␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -2818,7 +2877,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.Get(context.Background(), api.FoosGetRequest{FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33")})␊ + client.Foos.Get(␊ + context.Background(),␊ + api.FoosGetRequest{␊ + FooId: api.String("8d7e0b3a-b889-49a7-9164-4b71a0506a33"),␊ + },␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -2957,7 +3021,12 @@ Generated by [AVA](https://avajs.dev). import api "github.com/seamapi/go"␊ ␊ func main() {␊ - client.Foos.List(context.Background(), api.FoosListRequest{ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")}})␊ + client.Foos.List(␊ + context.Background(),␊ + api.FoosListRequest{␊ + ObjectProp: api.FoosListRequestObjectProp{Foo: api.String("bar")},␊ + },␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3108,7 +3177,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Transport.Air.Planes.List(context.Background())␊ + client.Transport.Air.Planes.List(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3234,7 +3304,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Transport.Air.Planes.List(context.Background())␊ + client.Transport.Air.Planes.List(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3360,7 +3431,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Transport.Air.Planes.List(context.Background())␊ + client.Transport.Air.Planes.List(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3502,7 +3574,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Deprecated.Undocumented.Endpoint(context.Background())␊ + client.Deprecated.Undocumented.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3619,7 +3692,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Deprecated.Undocumented.Endpoint(context.Background())␊ + client.Deprecated.Undocumented.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3736,7 +3810,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Deprecated.Undocumented.Endpoint(context.Background())␊ + client.Deprecated.Undocumented.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3869,7 +3944,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Draft.Endpoint(context.Background())␊ + client.Draft.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -3986,7 +4062,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Draft.Endpoint(context.Background())␊ + client.Draft.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ @@ -4103,7 +4180,8 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ func main() {␊ - client.Draft.Endpoint(context.Background())␊ + client.Draft.Endpoint(context.Background(),␊ + )␊ }`, request_syntax: 'go', response: `// go␊ diff --git a/test/snapshots/blueprint.test.ts.snap b/test/snapshots/blueprint.test.ts.snap index fb81b9b8..45401666 100644 Binary files a/test/snapshots/blueprint.test.ts.snap and b/test/snapshots/blueprint.test.ts.snap differ