-
Notifications
You must be signed in to change notification settings - Fork 86
JacksonModelAttributeSnippet now resolves all types #439
Conversation
protected Type getType(HandlerMethod method) { | ||
return documentationType; | ||
protected Type[] getType(HandlerMethod method) { | ||
return documentationType == null ? null : new Type[] {documentationType}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative here could be Optional.ofNullable(documentationType).map(type -> new Type[]{type}).orElse(null)
, but I wasn't sure if you like that fancy way.
protected Type getType(HandlerMethod method) { | ||
return documentationType; | ||
protected Type[] getType(HandlerMethod method) { | ||
return documentationType == null ? null : new Type[]{documentationType}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative here could be Optional.ofNullable(documentationType).map(type -> new Type[]{type}).orElse(null)
, but I wasn't sure if you like that fancy way.
2ffe6bd
to
0e3a2c5
Compare
0e3a2c5
to
9da097a
Compare
...tdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonModelAttributeSnippet.java
Show resolved
Hide resolved
|
||
assertThat(this.generatedSnippets.snippet(AUTO_MODELATTRIBUTE)).is( | ||
tableWithHeader("Parameter", "Type", "Optional", "Description") | ||
.row("field1", "String", "true", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field in Item
is annotated as @NotBlank
. I'm not sure these annotations work for ModelAttribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a look at this later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The detection of the ModelAttribute without an annotation didn't work. I implemented that ModelAttribute detection according to what you've stated in #426:
Any other argument | If a method argument is not matched to any of the earlier values in this table and it is a simple type (as determined by BeanUtils#isSimpleProperty, it is a resolved as a @RequestParam. Otherwise, it is resolved as a @ModelAttribute. |
---|
...tdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonModelAttributeSnippet.java
Outdated
Show resolved
Hide resolved
Looks great! Let's merge it. |
No description provided.