Skip to content

Commit

Permalink
feat: Add use-numeric-enum-json option. (#625)
Browse files Browse the repository at this point in the history
If this option is enabled, the JSON encoder (toJSON) will encode enum
values as integer, rather than the string.
  • Loading branch information
kev0960 committed Jul 28, 2022
1 parent 42a06b7 commit cd53d8c
Show file tree
Hide file tree
Showing 10 changed files with 794 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ Generated code will be placed in the Gradle build directory.
Requires `onlyTypes=true`. Implies `useDate=string` and `stringEnums=true`. This option is to generate types that can be directly used with marshalling/unmarshalling Protobuf messages serialized as JSON.
You may also want to set `useOptionals=all`, as gRPC gateways are not required to send default value for scalar values.

- With '--ts_proto_opt=useNumericEnumForJson=true`, the JSON converter (`toJSON`) will encode enum values as int, rather than a string literal.

### NestJS Support

We have a great way of working together with [nestjs](https://docs.nestjs.com/microservices/grpc). `ts-proto` generates `interfaces` and `decorators` for you controller, client. For more information see the [nestjs readme](NESTJS.markdown).
Expand Down
Loading

0 comments on commit cd53d8c

Please sign in to comment.