You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Testpublicvoidcreate() throwsException {
//whenBookDtobook = BookDto.builder().isbn("0-9705-6867-3").title("A Time To Kill").author(AuthorDto.builder().firstName("John").lastName("Grisham").build()).build();
CreateBookRequestDtocreateBookRequestDto = CreateBookRequestDto.builder().title("A Time To Kill").author(AuthorDto.builder().firstName("John").lastName("Grisham").build()).build();
when(bookService.create(any())).thenReturn(book);
//thenConstrainedFieldsconstrainedFields = newConstrainedFields(CreateBookRequestDto.class);
mvc
.perform(post("/books")
.content(newObjectMapper().writeValueAsBytes(createBookRequestDto))
.contentType(APPLICATION_JSON_VALUE)
.accept(APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
.andDo(print())
.andDo(
document(
"create-book",
resourceDetails().description("Create a book."),
requestFields(
constrainedFields.withPath("title").description("The title of the book."),
constrainedFields.withPath("author").description("The Author of the book."),
constrainedFields.withMappedPath("author.firstName", "author").description("The author's first name."),
constrainedFields.withMappedPath("author.lastName", "author").description("The author's last name.")
),
responseFields(
fieldWithPath("isbn").description("The ISBN of the book."),
fieldWithPath("title").description("The title of the book."),
fieldWithPath("author.firstName").description("The author's first name."),
fieldWithPath("author.lastName").description("The author's last name.")
)
)
);
}
Generated openapi-3.0.yml file. As you can see below, author should be required but it doesn't show up in the required fields.
components:
schemas:
books-1095758460:
required:
- titletype: objectproperties:
author:
required:
- firstName
- lastNametype: objectproperties:
lastName:
type: stringdescription: The author's last name.firstName:
type: stringdescription: The author's first name.description: The Author of the book.title:
minLength: 1type: stringdescription: The title of the book.
Is it a bug or am I missing something?
The text was updated successfully, but these errors were encountered:
I'm trying to use ConstrainedFields for Bean Validation but unable to get it to work.
As you can see below, CreateBookRequestDto has property 'author' and it should not be null.
Generated openapi-3.0.yml file. As you can see below, author should be required but it doesn't show up in the required fields.
Is it a bug or am I missing something?
The text was updated successfully, but these errors were encountered: