Thanks for reporting an issue for Micronaut, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
@Entity
@Table(name = "course")
@Data
public class Course {
@Id
Long id;
String level;
String name;
}
2. Create a controller method that consumes JSON, and has a body parameter that is a reference from a nested JSON attribute:
```java
@Post(value = "/propg/alunoRegular", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
public HttpResponse<Alumn> createAlumn(@Valid @Body("course") Course curse)
Send the following JSON:
{
"name": "Test Name",
"course": {
"id": 4815
}
}
Debug and watch the value of the course variable.
Expected Behaviour
Course variable has to be instantiated with id value equal to 4815 and null in name attribute.
Actual Behaviour
Course variable has is instantiated with id value null and name attribute as "Test Name".
If a create another parameter, like this:
@Data
public class DataFromCourse {
Course course;
}
The variable dataFromCourse is instantiated as expected, with the course attribute ìnstantiated with id 4815. So, the value of the Body Annotation is ignored, different from the class documentation suggests:
/**
* @return A Key or qualifier within the body. For example a reference to a nested JSON attribute
*/
@AliasFor(annotation = Bindable.class, member = "value")
String value() default ""
Environment Information
Operating System: Linux Mint
Micronaut Version: 1.2.0
JDK Version: openjdk version "1.8.0_172"
OpenJDK Runtime Environment (Zulu 8.30.0.1-linux64) (build 1.8.0_172-b01)
OpenJDK 64-Bit Server VM (Zulu 8.30.0.1-linux64) (build 25.172-b01, mixed mode)
Thanks for reporting an issue for Micronaut, please review the task list below before submitting the issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.
Task List
Steps to Reproduce
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table;
@Entity @Table(name = "course") @Data public class Course {
}
Expected Behaviour
Course variable has to be instantiated with id value equal to 4815 and null in name attribute.
Actual Behaviour
Course variable has is instantiated with id value null and name attribute as "Test Name". If a create another parameter, like this:
And the following class
The variable dataFromCourse is instantiated as expected, with the course attribute ìnstantiated with id 4815. So, the value of the Body Annotation is ignored, different from the class documentation suggests:
Environment Information
Example Application
Very simple example.