@@ -1020,6 +1020,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1020
1020
property .maxLength = sp .getMaxLength ();
1021
1021
property .minLength = sp .getMinLength ();
1022
1022
property .pattern = sp .getPattern ();
1023
+ property .isString = true ;
1023
1024
if (sp .getEnum () != null ) {
1024
1025
List <String > _enum = sp .getEnum ();
1025
1026
property ._enum = _enum ;
@@ -1034,6 +1035,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1034
1035
1035
1036
if (p instanceof IntegerProperty ) {
1036
1037
IntegerProperty sp = (IntegerProperty ) p ;
1038
+ property .isInteger = true ;
1037
1039
if (sp .getEnum () != null ) {
1038
1040
List <Integer > _enum = sp .getEnum ();
1039
1041
property ._enum = new ArrayList <String >();
@@ -1051,6 +1053,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1051
1053
1052
1054
if (p instanceof LongProperty ) {
1053
1055
LongProperty sp = (LongProperty ) p ;
1056
+ property .isLong = true ;
1054
1057
if (sp .getEnum () != null ) {
1055
1058
List <Long > _enum = sp .getEnum ();
1056
1059
property ._enum = new ArrayList <String >();
@@ -1066,8 +1069,21 @@ public CodegenProperty fromProperty(String name, Property p) {
1066
1069
}
1067
1070
}
1068
1071
1072
+ if (p instanceof BooleanProperty ) {
1073
+ property .isBoolean = true ;
1074
+ }
1075
+
1076
+ if (p instanceof BinaryProperty ) {
1077
+ property .isBinary = true ;
1078
+ }
1079
+
1080
+ if (p instanceof ByteArrayProperty ) {
1081
+ property .isByteArray = true ;
1082
+ }
1083
+
1069
1084
if (p instanceof DoubleProperty ) {
1070
1085
DoubleProperty sp = (DoubleProperty ) p ;
1086
+ property .isDouble = true ;
1071
1087
if (sp .getEnum () != null ) {
1072
1088
List <Double > _enum = sp .getEnum ();
1073
1089
property ._enum = new ArrayList <String >();
@@ -1085,6 +1101,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1085
1101
1086
1102
if (p instanceof FloatProperty ) {
1087
1103
FloatProperty sp = (FloatProperty ) p ;
1104
+ property .isFloat = true ;
1088
1105
if (sp .getEnum () != null ) {
1089
1106
List <Float > _enum = sp .getEnum ();
1090
1107
property ._enum = new ArrayList <String >();
@@ -1102,6 +1119,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1102
1119
1103
1120
if (p instanceof DateProperty ) {
1104
1121
DateProperty sp = (DateProperty ) p ;
1122
+ property .isDate = true ;
1105
1123
if (sp .getEnum () != null ) {
1106
1124
List <String > _enum = sp .getEnum ();
1107
1125
property ._enum = new ArrayList <String >();
@@ -1119,6 +1137,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1119
1137
1120
1138
if (p instanceof DateTimeProperty ) {
1121
1139
DateTimeProperty sp = (DateTimeProperty ) p ;
1140
+ property .isDateTime = true ;
1122
1141
if (sp .getEnum () != null ) {
1123
1142
List <String > _enum = sp .getEnum ();
1124
1143
property ._enum = new ArrayList <String >();
@@ -1146,6 +1165,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1146
1165
1147
1166
if (p instanceof ArrayProperty ) {
1148
1167
property .isContainer = true ;
1168
+ property .isListContainer = true ;
1149
1169
property .containerType = "array" ;
1150
1170
ArrayProperty ap = (ArrayProperty ) p ;
1151
1171
CodegenProperty cp = fromProperty (property .name , ap .getItems ());
@@ -1168,6 +1188,7 @@ public CodegenProperty fromProperty(String name, Property p) {
1168
1188
}
1169
1189
} else if (p instanceof MapProperty ) {
1170
1190
property .isContainer = true ;
1191
+ property .isMapContainer = true ;
1171
1192
property .containerType = "map" ;
1172
1193
MapProperty ap = (MapProperty ) p ;
1173
1194
CodegenProperty cp = fromProperty ("inner" , ap .getAdditionalProperties ());
@@ -1575,7 +1596,7 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
1575
1596
if (null == type ) {
1576
1597
LOGGER .warn ("Type is NULL for Serializable Parameter: " + param );
1577
1598
}
1578
- if ("array" .equals (type )) {
1599
+ if ("array" .equals (type )) { // for array parameter
1579
1600
Property inner = qp .getItems ();
1580
1601
if (inner == null ) {
1581
1602
LOGGER .warn ("warning! No inner type supplied for array parameter \" " + qp .getName () + "\" , using String" );
@@ -1589,8 +1610,9 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
1589
1610
CodegenProperty pr = fromProperty ("inner" , inner );
1590
1611
p .baseType = pr .datatype ;
1591
1612
p .isContainer = true ;
1613
+ p .isListContainer = true ;
1592
1614
imports .add (pr .baseType );
1593
- } else if ("object" .equals (type )) {
1615
+ } else if ("object" .equals (type )) { // for map parameter
1594
1616
Property inner = qp .getItems ();
1595
1617
if (inner == null ) {
1596
1618
LOGGER .warn ("warning! No inner type supplied for map parameter \" " + qp .getName () + "\" , using String" );
@@ -1600,19 +1622,26 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
1600
1622
collectionFormat = qp .getCollectionFormat ();
1601
1623
CodegenProperty pr = fromProperty ("inner" , inner );
1602
1624
p .baseType = pr .datatype ;
1625
+ p .isContainer = true ;
1626
+ p .isMapContainer = true ;
1603
1627
imports .add (pr .baseType );
1604
1628
} else {
1605
1629
Map <PropertyId , Object > args = new HashMap <PropertyId , Object >();
1606
1630
String format = qp .getFormat ();
1607
1631
args .put (PropertyId .ENUM , qp .getEnum ());
1608
1632
property = PropertyBuilder .build (type , format , args );
1609
1633
}
1634
+
1610
1635
if (property == null ) {
1611
1636
LOGGER .warn ("warning! Property type \" " + type + "\" not found for parameter \" " + param .getName () + "\" , using String" );
1612
1637
property = new StringProperty ().description ("//TODO automatically added by swagger-codegen. Type was " + type + " but not supported" );
1613
1638
}
1614
1639
property .setRequired (param .getRequired ());
1615
1640
CodegenProperty model = fromProperty (qp .getName (), property );
1641
+
1642
+ // set boolean flag (e.g. isString)
1643
+ setParameterBooleanFlagWithCodegenProperty (p , model );
1644
+
1616
1645
p .dataType = model .datatype ;
1617
1646
p .isEnum = model .isEnum ;
1618
1647
p ._enum = model ._enum ;
@@ -1663,6 +1692,9 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
1663
1692
p .dataType = cp .datatype ;
1664
1693
p .isBinary = cp .datatype .toLowerCase ().startsWith ("byte" );
1665
1694
}
1695
+
1696
+ // set boolean flag (e.g. isString)
1697
+ setParameterBooleanFlagWithCodegenProperty (p , cp );
1666
1698
}
1667
1699
} else if (model instanceof ArrayModel ) {
1668
1700
// to use the built-in model parsing, we unwrap the ArrayModel
@@ -1678,6 +1710,10 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
1678
1710
imports .add (cp .baseType );
1679
1711
p .dataType = cp .datatype ;
1680
1712
p .isContainer = true ;
1713
+ p .isListContainer = true ;
1714
+
1715
+ // set boolean flag (e.g. isString)
1716
+ setParameterBooleanFlagWithCodegenProperty (p , cp );
1681
1717
} else {
1682
1718
Model sub = bp .getSchema ();
1683
1719
if (sub instanceof RefModel ) {
@@ -2157,6 +2193,8 @@ public void setLibrary(String library) {
2157
2193
2158
2194
/**
2159
2195
* Library template (sub-template).
2196
+ *
2197
+ * @return Library template
2160
2198
*/
2161
2199
public String getLibrary () {
2162
2200
return library ;
@@ -2221,10 +2259,10 @@ public String sanitizeName(String name) {
2221
2259
}
2222
2260
2223
2261
/**
2224
- * only write if the file doesn't exist
2262
+ * Only write if the file doesn't exist
2225
2263
*
2226
- * @param outputFolder
2227
- * @param supportingFile
2264
+ * @param outputFolder Output folder
2265
+ * @param supportingFile Supporting file
2228
2266
*/
2229
2267
public void writeOptional (String outputFolder , SupportingFile supportingFile ) {
2230
2268
String folder = "" ;
@@ -2243,4 +2281,46 @@ public void writeOptional(String outputFolder, SupportingFile supportingFile) {
2243
2281
supportingFiles .add (supportingFile );
2244
2282
}
2245
2283
}
2284
+
2285
+ /**
2286
+ * Set CodegenParameter boolean flag using CodegenProperty.
2287
+ *
2288
+ * @param parameter Codegen Parameter
2289
+ * @param property Codegen property
2290
+ */
2291
+ public void setParameterBooleanFlagWithCodegenProperty (CodegenParameter parameter , CodegenProperty property ) {
2292
+ if (parameter == null ) {
2293
+ LOGGER .error ("Codegen Parameter cannnot be null." );
2294
+ return ;
2295
+ }
2296
+
2297
+ if (property == null ) {
2298
+ LOGGER .error ("Codegen Property cannot be null." );
2299
+ return ;
2300
+ }
2301
+
2302
+ if (Boolean .TRUE .equals (property .isString )) {
2303
+ parameter .isString = true ;
2304
+ } else if (Boolean .TRUE .equals (property .isBoolean )) {
2305
+ parameter .isBoolean = true ;
2306
+ } else if (Boolean .TRUE .equals (property .isLong )) {
2307
+ parameter .isLong = true ;
2308
+ } else if (Boolean .TRUE .equals (property .isInteger )) {
2309
+ parameter .isInteger = true ;
2310
+ } else if (Boolean .TRUE .equals (property .isDouble )) {
2311
+ parameter .isDouble = true ;
2312
+ } else if (Boolean .TRUE .equals (property .isFloat )) {
2313
+ parameter .isFloat = true ;
2314
+ } else if (Boolean .TRUE .equals (property .isByteArray )) {
2315
+ parameter .isByteArray = true ;
2316
+ } else if (Boolean .TRUE .equals (property .isBinary )) {
2317
+ parameter .isByteArray = true ;
2318
+ } else if (Boolean .TRUE .equals (property .isDate )) {
2319
+ parameter .isDate = true ;
2320
+ } else if (Boolean .TRUE .equals (property .isDateTime )) {
2321
+ parameter .isDateTime = true ;
2322
+ } else {
2323
+ LOGGER .debug ("Property type is not primitive: " + property .datatype );
2324
+ }
2325
+ }
2246
2326
}
0 commit comments