Option "useProtoFieldName" to generate interfaces in snake_case
See original GitHub issueI use protobuf-ts in my project like this Example proto
syntax = "proto3";
message MyMessage {
int32 foo_bar = 1;
}
Output interface after compilation
export interface MyMessage {
fooBar: number;
/* I want to have
foo_bar: number;
*/
}
Usage
const message = MyMessage.fromBinary(buffer, { readUnknownField: false });
const result = MyMessage.toJson(message, {
emitDefaultValues: false,
useProtoFieldName: true,
});
result
looks like { foo_bar: 1 }
. But I can’t cast it const result: MyMessage
because MyMessage
has fields in camelCase.
Are you agree to add such option to ts_opt
? If yes I can help you and create PR for that 😃
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
protoc-gen-go: support using proto field names as JSON names
An implementation may provide an option to use proto field name as the JSON name instead. Proto3 JSON parsers are required to accept...
Read more >Language Guide (proto3) | Protocol Buffers - Google Developers
This guide describes how to use the protocol buffer language to structure your protocol buffer data, including .proto file syntax and how to...
Read more >Is it possible to use mapped types in Typescript to change a ...
I am trying to figure out a way to use mapped types to change a types keys from camel to snake case. For...
Read more >StyleGuide - TypeScript Deep Dive - Gitbook
Interface. Use PascalCase for name. Reason: Similar to class. Use camelCase for members. Reason: Similar to class. Don't prefix with I.
Read more >Snake case to Camel case: bring peace between Rails and ...
Developing software by conventions produce easy-to-read code and ... models/active.interface';; import { camelCase, snakeCase } from ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been addressed in https://github.com/timostamm/protobuf-ts/pull/250 which was released in v2.3.0.
Thanks, I’ll take a look to use ts-proto to generate interfaces