We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
With this record:
package com.example; import io.micronaut.core.annotation.Introspected; import io.micronaut.serde.annotation.Serdeable; import java.util.List; @Serdeable public record QuestionSave(String question, List<Long> usersId) { }
and this controller:
package com.example; import io.micronaut.http.MediaType; import io.micronaut.http.annotation.Body; import io.micronaut.http.annotation.Consumes; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Post; @Controller("/questions") public class QuestionController { @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Post("/save") QuestionSave save(@Body QuestionSave questionSave) { return questionSave; } }
and this test fails when the list contains one item:
package com.example; import io.micronaut.http.HttpRequest; import io.micronaut.http.MediaType; import io.micronaut.http.client.BlockingHttpClient; import io.micronaut.http.client.HttpClient; import io.micronaut.http.client.annotation.Client; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import org.junit.jupiter.api.Test; import java.io.IOException; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; @MicronautTest class QuestionControllerTest { @Test ❌ public void formWithListOfOneItem(@Client("/") HttpClient client) throws IOException { String body = "question=en+que+trabajas&usersId=1"; String expectedJson = "{\"question\":\"en que trabajas\",\"usersId\":[1]}"; assertWithBody(client, body, expectedJson); } @Test ✅ public void formWithListOfMoreThanOne(@Client("/") HttpClient client) throws IOException { String body = "question=en+que+trabajas&usersId=1&usersId=2"; String expectedJson = "{\"question\":\"en que trabajas\",\"usersId\":[1,2]}"; assertWithBody(client, body, expectedJson); } private static void assertWithBody(HttpClient httpClient, String body, String expectedJson) throws IOException { BlockingHttpClient client = httpClient.toBlocking(); String json = assertDoesNotThrow(() -> client.retrieve(HttpRequest.POST("/questions/save", body).contentType(MediaType.APPLICATION_FORM_URLENCODED_TYPE))); assertEquals(expectedJson, json); } }
Both test pass when using Micronaut Jackson Databind.
The text was updated successfully, but these errors were encountered:
tck: form-url-encoded with field with list
6051bd4
see: micronaut-projects/micronaut-serialization#616
tck: form-url-encoded with field with list (#10023)
fb4ee2e
* tck: form-url-encoded with field with list see: micronaut-projects/micronaut-serialization#616 * remove unused imports
this is now fixed in Micronaut Framework 4.2.0
Sorry, something went wrong.
No branches or pull requests
Issue description
With this record:
and this controller:
and this test fails when the list contains one item:
Both test pass when using Micronaut Jackson Databind.
The text was updated successfully, but these errors were encountered: