skryukov / typelizer

A TypeScript type generator for Ruby serializers.
48 stars 2 forks source link

Feature request: Generating multiple type definitions with prefix/suffix and modification #12

Open okuramasafumi opened 3 days ago

okuramasafumi commented 3 days ago

Motivation

We want to generate two types, one is snake_case_key and another is camelCaseKey because our React app wants camelCaseKey for internal use, but also Rails API outputs snake_case_key. Currently we transform types with TypeScript, but it is difficult to understand, so it's better to let Typelizer do that.

Details

Currently we can modify keys with something like config.properties_transformer = ->(properties) { properties.map{ _1.name = _1.name.to_s.camelize and _1 } } but this makes all keys camelCase. Basically we want to do generation twice.

We have Generator class and Writer class. Should we have multiple generators, or writers?

Additional info

It's more like a discussion rather than an issue. I'd love to implement this feature if we reach some conclusion.

skryukov commented 3 days ago

Hey @okuramasafumi, thanks for the feature request! Yes, I think multiple outputs make sense for generating input/output types with different configurations. null_strategy might be another option one might want to modify. I can't comment on implementation details right away, but I like the idea.