Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef61071

Browse files
committed
Changed the xml name to default to the model name when missing
(1907)
1 parent 94acab9 commit ef61071

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

springfox-core/src/main/java/springfox/documentation/builders/ModelBuilder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.List;
2828
import java.util.Map;
2929

30+
import static com.google.common.base.Strings.*;
3031
import static com.google.common.collect.Lists.*;
3132
import static com.google.common.collect.Maps.*;
3233
import static springfox.documentation.builders.BuilderDefaults.*;
@@ -163,6 +164,9 @@ public ModelBuilder xml(Xml xml) {
163164
}
164165

165166
public Model build() {
167+
if (xml != null && isNullOrEmpty(xml.getName())) {
168+
xml.setName(name);
169+
}
166170
return new Model(
167171
id,
168172
name,

springfox-core/src/main/java/springfox/documentation/builders/ModelPropertyBuilder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import java.util.List;
2929

30+
import static com.google.common.base.Strings.*;
3031
import static com.google.common.collect.Lists.*;
3132
import static springfox.documentation.builders.BuilderDefaults.*;
3233

@@ -87,7 +88,7 @@ public ModelPropertyBuilder example(String example) {
8788
}
8889

8990
public ModelPropertyBuilder allowableValues(AllowableValues allowableValues) {
90-
this.allowableValues = emptyToNull(allowableValues, this.allowableValues);
91+
this.allowableValues = BuilderDefaults.emptyToNull(allowableValues, this.allowableValues);
9192
return this;
9293
}
9394

@@ -117,6 +118,9 @@ public ModelPropertyBuilder xml(Xml xml) {
117118
}
118119

119120
public ModelProperty build() {
121+
if (xml != null && isNullOrEmpty(xml.getName())) {
122+
xml.setName(name);
123+
}
120124
return new ModelProperty(
121125
name,
122126
type,

0 commit comments

Comments
 (0)