Replies: 1 comment 1 reply
-
At the moment no, I think in a next release we probably want to be able to attach tags to MapOutputName and MapInputName, something like this: #[MapOutputName(SnakeCaseMapper::class, 'array')] -> would then be used to map names in array responses Let's say you've got camel case names and want snake typescript names: #[MapOutputName(SnakeCaseMapper::class, 'typescript')] By default when adding no tags everything would be mapped: #[MapOutputName(SnakeCaseMapper::class)] This would also solve issues where when mapping data to the database models also could specify its casing while having another casing for requests:
It would be cool if people would be able to define their own mapping tags like
Which could be used with: $data->transform(TransformContextFactory::create()->mapOutputNamesFor('ios-app')) I'll add it to my list for data v5 but would certainly accept PR's so this can be added in earlier! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In our project, we'd like to use
camelCase
on the frontend and in our Data objects, but still usesnake_case
in the models/database.For this, I've created something like the following:
It works great when calling
$data->toArray()
, but the issue is thatDataTypeScriptTransformer
will also usesnake_case
property names for the TS definition, resulting in this:This is an issue, because we do not use snake_case on the frontend - this DTO is used specifically to map camelCase frontend data to snake_case for the backend, when creating a new product.
Is there any way to ignore the mapped output names when transforming the data class for the frontend?
Beta Was this translation helpful? Give feedback.
All reactions