Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

JacksonModelAttributeSnippet now resolves all types #439

Merged
merged 5 commits into from
Feb 17, 2021

Conversation

mustaphazorgati
Copy link
Contributor

@mustaphazorgati mustaphazorgati commented Feb 2, 2021

No description provided.

protected Type getType(HandlerMethod method) {
return documentationType;
protected Type[] getType(HandlerMethod method) {
return documentationType == null ? null : new Type[] {documentationType};
Copy link
Contributor Author

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};
Copy link
Contributor Author

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.

@mustaphazorgati mustaphazorgati force-pushed the 426-1 branch 2 times, most recently from 2ffe6bd to 0e3a2c5 Compare February 3, 2021 12:42

assertThat(this.generatedSnippets.snippet(AUTO_MODELATTRIBUTE)).is(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("field1", "String", "true", "")
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@jmisur
Copy link
Contributor

jmisur commented Feb 17, 2021

Looks great! Let's merge it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants