-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Milestone
Description
Noting #539 was closed with a preference for some concrete examples, I have been migrating an existing REST backend to Avaje and noticed two situations where it would have been helpful to have the ability to provide a custom converter for path and query parameters:
- The use of
Ulid
(from https://github.com/f4b6a3/ulid-creator/tree/master). The workaround is treat it as a string and convert in the method. Alternately it would be ideal if there was some way to detect common open source libraries people are using and provide the conversion in-place within the generated source. - The use of enums which are not encoded as strings compatible with
Enum.valueOf(Class<T extends Enum>, String)
. This is a more significant limitation as you need to either pass the enum values as strings for your ownstatic Enum from(String value)
method or refactor to a JSON type withPOST
so you can access something like Avaje JsonB (which is what I did). It is particularly unfortunate if the enum is a@Json
anyway (eg with@Json.Value
) as it should prefer to use that as you already have an idiomatic string to enum mechanism already in place via the Avaje ecosystem.
As an aside it would have been good to work around the second scenario via a @Filter
by way of replacing the query parameters, but it doesn't seem possible to replace the request passed through the chain (which is what the servlet API offers and would have for example enabled normalisation of the query parameters obtained from Context.queryParams(String)
with something that would be Enum.valueOf(..)
compatible).
Metadata
Metadata
Assignees
Labels
No labels