apitte icon indicating copy to clipboard operation
apitte copied to clipboard

Custom parameter mapping types

Open northys opened this issue 4 years ago • 4 comments

When I saw this part of documentation about overriding mapping datatypes I immediately created my own UuidTypeMapper and registered it like

api:
    plugins:
        Apitte\Core\DI\Plugin\CoreMappingPlugin:
            types:
                uuid: App\Api\Mapping\Parameter\UuidTypeMapper

This is not supported though. Is there any way to add custom parameter mapping types? I'm not yet much familiar with the library codebase but from what I already saw it shouldn't be hard to implement. Maybe I could take a look at it but not this month. I have to finish something before deadline :D

Now I'm confused about dupllication of checks in multiple plugin and I think this must be fixed to implement this. Validation in CoreSchemaPlugin raises exception https://github.com/apitte/core/blob/c99c923ba006896a685a5d5b27fcdcc7d9432e49/src/Schema/Validation/RequestParameterValidation.php#L48 using in_array check inside array of hardcoded types. While CoreMappingPlugin does the actual mapping and is the one who registers the mappers. This array of mappers (their keys respectively) must be somehow passed to RequestParameterValidation inside CoreSchemaPlugin.

northys avatar May 30 '21 00:05 northys

I see. Validation is a problem here. Great report.

f3l1x avatar May 31 '21 14:05 f3l1x

@f3l1x Is there any work done on this already? In one of our apps it would be very useful to define custom types. I can try to prepare PR

MartinMystikJonas avatar Sep 12 '22 16:09 MartinMystikJonas

@f3l1x I prepared PR that would allow custom mapping types to be added. Could you check it out? See https://github.com/contributte/apitte/pull/187

MartinMystikJonas avatar Sep 13 '22 08:09 MartinMystikJonas

Just btw - I'm no longer a programmer so I can't check it nor test it...

northys avatar Sep 13 '22 09:09 northys

Done in #187

f3l1x avatar Jul 04 '23 10:07 f3l1x