You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our project, we'd like to use camelCase on the frontend and in our Data objects, but still use snake_case in the models/database.
For this, I've created something like the following:
#[TypeScript]
#[TypeScriptTransformer(DataTypeScriptTransformer::class)]
#[MapOutputName(SnakeCaseMapper::class)]
class CreateProductData extends Data {
publicstring$name;
publicstring$variantName;
}
It works great when calling $data->toArray(), but the issue is that DataTypeScriptTransformer will also use snake_case property names for the TS definition, resulting in this:
exporttypeCreateProductData={name: stringvariant_name: string// not what we want - should be `variantName`!}
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?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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