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

Declarative HTTP client - @Format annotation ignored for form body arguments #9882

Closed
oujesky opened this issue Sep 15, 2023 · 0 comments · Fixed by #9883
Closed

Declarative HTTP client - @Format annotation ignored for form body arguments #9882

oujesky opened this issue Sep 15, 2023 · 0 comments · Fixed by #9883
Labels
type: enhancement New feature or request

Comments

@oujesky
Copy link
Contributor

oujesky commented Sep 15, 2023

Expected Behavior

@Client("/")
public interface SomeClient {
    @Post("/form/body")
    @Produces(MediaType.APPLICATION_FORM_URLENCODED)
    HttpResponse<String> sendFormattedFormParameter(@Format("yyyy/MM/dd") LocalDate bodyDate);
}

...

client.sendFormattedFormParameter(LocalDate.of(2023, 9, 8));

when executed, request URL-encoded form body contains bodyDate=2023%2F09%2F08 as specified with the @Format("yyyy/MM/dd") annotation

Actual Behaviour

when executed, request URL-encoded form body contains bodyDate=2023-09-08

  • the @Format annotation seems to be ignored when client method arguments are passed into URL-encoded form body
  • the @Format annotation correctly works for query parameters

Steps To Reproduce

please see example application

  • execute FormFormatTest
  • the test FormFormatTest#testFormParameter() will fail with Expected: 2023/09/08 Actual: 2023-09-08
  • the client with @Format annotation is defined in FormFormatClient

Environment Information

  • JDK 17
  • MacOS

Example Application

https://github.com/oujesky/micronaut-client-format-bug

Version

4.1.0

@yawkat yawkat added the type: enhancement New feature or request label Oct 24, 2023
graemerocher pushed a commit that referenced this issue Oct 25, 2023
…uments (#9883)

Should resolve #9882

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: micronaut-build <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants