Skip to content
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

Enhancement: json_name defined in a proto file should be able to be extracted. #942

Closed
Yo-mah-Ya opened this issue Oct 9, 2023 · 1 comment

Comments

@Yo-mah-Ya
Copy link
Contributor

Yo-mah-Ya commented Oct 9, 2023

I'm wondering if we could support to get only interface declaration with json_name defined in a proto file, in other words when onlyTypes=true are set, wanna get fields from json_name defined in a proto file.

For example, I want the json_name named Alias shown below proto file. The first letter should be capitalized !
https://github.com/pganalyze/libpg_query/blob/009f19d7f867a699e1beab5fd545fbc07ad35647/protobuf/pg_query.proto#L19

But as long as I see the below part, it seems that only field name, possibly modified by maybeSnakeToCamel though, is supported.

ts-proto/src/main.ts

Lines 877 to 880 in 1283602

const name = maybeSnakeToCamel(fieldDesc.name, options);
const isOptional = isOptionalProperty(fieldDesc, messageDesc.options, options);
const type = toTypeName(ctx, messageDesc, fieldDesc, isOptional);
chunks.push(code`${maybeReadonly(options)}${name}${isOptional ? "?" : ""}: ${type}, `);

Ideally I'd like to get field name like shown below.
https://github.com/thesayyn/protoc-gen-ts/blob/a5c306a0d1d864ce5bc1887dfef078d76c0efcc0/src/descriptor.ts#L15-L20

@Yo-mah-Ya Yo-mah-Ya changed the title Enhancement: json_name should be able to be extracted even when outputJsonMethods=false is given. Enhancement: json_name defined in a proto file should be able to be extracted. Oct 9, 2023
@stephenh
Copy link
Owner

Fixed in #943 , thanks @Yo-mah-Ya !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants