Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatters are not utilized #4

Open
rburgst opened this issue Dec 2, 2018 · 1 comment
Open

formatters are not utilized #4

rburgst opened this issue Dec 2, 2018 · 1 comment
Labels
type: enhancement New feature or request

Comments

@rburgst
Copy link

rburgst commented Dec 2, 2018

Custom formatters are not available: See

https://github.com/rburgst/micronaut-spring-example

The gist ist that you would define custom type converters for REST controller methods via the FormatterRegistry

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addFormatterForFieldType(TenantId.class, 
          new GenericIdFormatter(TenantId.class));
    }
}

These are not used/initialized by micronaut-spring, therefore the following request fails:

$ http ":8080/greet?tenantId=7364b7d8-490d-49b9-8e18-7b96f41734e8"


HTTP/1.1 400 Bad Request
Date: Sun, 2 Dec 2018 09:16:43 GMT
connection: close
content-length: 184
content-type: application/json

{
    "_links": {
        "self": {
            "href": "/greet?tenantId=7364b7d8-490d-49b9-8e18-7b96f41734e8",
            "templated": false
        }
    },
    "message": "Required argument [TenantId tenantId] not specified",
    "path": "/tenantId"
}

To replicate the problem, launch the application via

./gradlew bootRun

and send the above mentioned request.

@graemerocher
Copy link
Contributor

I guess we could probably adapt formatters to the binder API, will see what we can do. Thanks for the feedback

@graemerocher graemerocher added type: enhancement New feature or request and removed enhancement labels Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants