Skip to content

Commit 7d95fe4

Browse files
authored
fix latest JsonEncode method change (#51)
* fix latest JsonEncode method change * update
1 parent 5052e6e commit 7d95fe4

7 files changed

Lines changed: 12 additions & 12 deletions

File tree

_examples/node-ts/server-fastify/server.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const validateType = (value: any, type: string) => {
236236
}
237237

238238

239-
export const JsonEncode = <T = any>(obj: T, _typ: string = ''): string => {
239+
export const JsonEncode = <T = any>(obj: T): string => {
240240
return JSON.stringify(obj)
241241
}
242242

_examples/node-ts/server-hono/server.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const validateType = (value: any, type: string) => {
236236
}
237237

238238

239-
export const JsonEncode = <T = any>(obj: T, _typ: string = ''): string => {
239+
export const JsonEncode = <T = any>(obj: T): string => {
240240
return JSON.stringify(obj)
241241
}
242242

_examples/node-ts/server/server.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const validateType = (value: any, type: string) => {
236236
}
237237

238238

239-
export const JsonEncode = <T = any>(obj: T, _typ: string = ''): string => {
239+
export const JsonEncode = <T = any>(obj: T): string => {
240240
return JSON.stringify(obj)
241241
}
242242

_examples/node-ts/webapp/client.gen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class Example implements ExampleClient {
123123
getUser = (req: GetUserRequest, headers?: object, signal?: AbortSignal): Promise<GetUserResponse> => {
124124
return this.fetch(
125125
this.url('GetUser'),
126-
createHttpRequest(JsonEncode(req, 'GetUserRequest'), headers, signal)).then((res) => {
126+
createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
127127
return buildResponse(res).then(_data => {
128128
return JsonDecode<GetUserResponse>(_data, 'GetUserResponse')
129129
})
@@ -135,7 +135,7 @@ export class Example implements ExampleClient {
135135
getArticle = (req: GetArticleRequest, headers?: object, signal?: AbortSignal): Promise<GetArticleResponse> => {
136136
return this.fetch(
137137
this.url('GetArticle'),
138-
createHttpRequest(JsonEncode(req, 'GetArticleRequest'), headers, signal)).then((res) => {
138+
createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
139139
return buildResponse(res).then(_data => {
140140
return JsonDecode<GetArticleResponse>(_data, 'GetArticleResponse')
141141
})
@@ -177,7 +177,7 @@ export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response
177177

178178

179179

180-
export const JsonEncode = <T = any>(obj: T, _typ: string = ''): string => {
180+
export const JsonEncode = <T = any>(obj: T): string => {
181181
return JSON.stringify(obj)
182182
}
183183

_examples/sse/webapp/client.gen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class Chat implements ChatClient {
9090
sendMessage = (req: SendMessageRequest, headers?: object, signal?: AbortSignal): Promise<SendMessageResponse> => {
9191
return this.fetch(
9292
this.url('SendMessage'),
93-
createHttpRequest(JsonEncode(req, 'SendMessageRequest'), headers, signal)).then((res) => {
93+
createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
9494
return buildResponse(res).then(_data => {
9595
return JsonDecode<SendMessageResponse>(_data, 'SendMessageResponse')
9696
})
@@ -110,7 +110,7 @@ export class Chat implements ChatClient {
110110
}
111111

112112
const _fetch = () => this.fetch(this.url('SubscribeMessages'),
113-
createHttpRequest(JsonEncode(req, 'SubscribeMessagesRequest'), options.headers, abortSignal)
113+
createHttpRequest(JsonEncode(req), options.headers, abortSignal)
114114
).then(async (res) => {
115115
await sseResponse(res, options, _fetch)
116116
}, (error) => {
@@ -321,7 +321,7 @@ export interface WebrpcStreamController {
321321

322322

323323

324-
export const JsonEncode = <T = any>(obj: T, _typ: string = ''): string => {
324+
export const JsonEncode = <T = any>(obj: T): string => {
325325
return JSON.stringify(obj)
326326
}
327327

bigintHelpers.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T =>
117117
return decodeType(typ, parsed) as T
118118
}
119119
{{- else}}
120-
{{- "\n\n" -}}export const JsonEncode = <T = any>(obj: T, _typ: string = ''): string => {
120+
{{- "\n\n" -}}export const JsonEncode = <T = any>(obj: T): string => {
121121
return JSON.stringify(obj)
122122
}
123123

client.go.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class {{$service.Name}} implements {{$service.Name}}Client {
6666
}
6767
6868
const _fetch = () => this.fetch(this.url('{{.Name}}'),
69-
{{if .Inputs | len }}createHttpRequest(JsonEncode(req, '{{$methodReqName}}'), options.headers, abortSignal){{- else}}createHttpRequest('{}', options.headers, options.signal){{end }}
69+
{{if .Inputs | len }}createHttpRequest(JsonEncode(req), options.headers, abortSignal){{- else}}createHttpRequest('{}', options.headers, options.signal){{end }}
7070
).then(async (res) => {
7171
await sseResponse(res, options, _fetch)
7272
}, (error) => {
@@ -83,7 +83,7 @@ export class {{$service.Name}} implements {{$service.Name}}Client {
8383
return this.fetch(
8484
this.url('{{.Name}}'),
8585
{{- if .Inputs | len }}
86-
createHttpRequest(JsonEncode(req, '{{$methodReqName}}'), headers, signal)).then((res) => {
86+
createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
8787
{{- else }}
8888
createHttpRequest('{}', headers, signal)).then((res) => {
8989
{{- end }}

0 commit comments

Comments
 (0)