Skip to content

Tate/fix json client #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.0.59

- Fixes generated JSON client when using nested messages. The generated JSON serialization names were invalid for nested messages. See [#176](https://github.com/tatethurston/TwirpScript/issues/176) for more context.

## v0.0.58

- Better insight into internal server Errors. TwirpScript catches any errors thrown internally. Errors that aren't an `instanceof` `TwirpError` present to users as a generic Twirp `internal_error` for security so that internal details don't leak. This can hurt the DX for identifying issues during development, and also can hide important debugging information when relying on error reporting using `hooks`.
Expand Down
2 changes: 1 addition & 1 deletion public.package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twirpscript",
"version": "0.0.58",
"version": "0.0.59",
"description": "Protobuf RPC framework for JavaScript and TypeScript",
"license": "MIT",
"author": "Tate <[email protected]>",
Expand Down
18 changes: 13 additions & 5 deletions src/autogenerate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,10 @@ export async function ${method.name}JSON(${input}${printIfTypescript(
)}, config${printIfTypescript(
`?: ClientConfiguration`
)})${printIfTypescript(`: Promise<${method.output}>`)} {
const response = await JSONrequest('${path}', ${
method.input
}JSON.encode(${input}), config);
return ${method.output}JSON.decode(response);
const response = await JSONrequest('${path}', ${addJSONSuffixToFullyQualifiedName(
method.input!
)}.encode(${input}), config);
return ${addJSONSuffixToFullyQualifiedName(method.output!)}.decode(response);
}

`;
Expand Down Expand Up @@ -868,7 +868,15 @@ function writeServers(
name: '${[packageName, service.name].filter(Boolean).join(".")}',
methods: {\n`;
service.methods.forEach((method) => {
result += `${method.name}: { name: '${method.name}', handler: service.${method.name}, input: { protobuf: ${method.input}, json: ${method.input}JSON }, output: { protobuf: ${method.output}, json: ${method.output}JSON } },`;
result += `${method.name}: { name: '${method.name}', handler: service.${
method.name
}, input: { protobuf: ${
method.input
}, json: ${addJSONSuffixToFullyQualifiedName(
method.input!
)} }, output: { protobuf: ${
method.output
}, json: ${addJSONSuffixToFullyQualifiedName(method.output!)} } },`;
});
result += "}\n";
result += `} ${printIfTypescript("as const")}\n`;
Expand Down
Loading