@@ -166,6 +166,9 @@ public String toParamName(String name) {
166
166
return name ;
167
167
}
168
168
169
+ public String toEnumName (CodegenProperty property ) {
170
+ return StringUtils .capitalize (property .name ) + "Enum" ;
171
+ }
169
172
170
173
public String escapeReservedWord (String name ) {
171
174
throw new RuntimeException ("reserved word " + name + " not allowed" );
@@ -470,6 +473,7 @@ else if (model instanceof RefModel) {
470
473
}
471
474
if (impl .getProperties () != null && impl .getProperties ().size () > 0 ) {
472
475
m .hasVars = true ;
476
+ m .hasEnums = false ;
473
477
for (String key : impl .getProperties ().keySet ()) {
474
478
Property prop = impl .getProperties ().get (key );
475
479
@@ -497,6 +501,8 @@ else if (model instanceof RefModel) {
497
501
}
498
502
m .vars .add (cp );
499
503
count += 1 ;
504
+ if (cp .isEnum )
505
+ m .hasEnums = true ;
500
506
if (count != impl .getProperties ().keySet ().size ())
501
507
cp .hasMore = new Boolean (true );
502
508
if (cp .isContainer != null ) {
@@ -589,7 +595,7 @@ public CodegenProperty fromProperty(String name, Property p) {
589
595
590
596
// this can cause issues for clients which don't support enums
591
597
if (property .isEnum )
592
- property .datatypeWithEnum = StringUtils . capitalize (property . name ) + "Enum" ;
598
+ property .datatypeWithEnum = toEnumName (property ) ;
593
599
else
594
600
property .datatypeWithEnum = property .datatype ;
595
601
@@ -722,7 +728,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
722
728
723
729
if (operation .getResponses () != null && !operation .getResponses ().isEmpty ()) {
724
730
Response methodResponse = findMethodResponse (operation .getResponses ());
725
- CodegenResponse methodCodegenResponse = null ;
726
731
727
732
for (Map .Entry <String , Response > entry : operation .getResponses ().entrySet ()) {
728
733
Response response = entry .getValue ();
@@ -732,9 +737,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
732
737
!defaultIncludes .contains (r .baseType ) &&
733
738
!languageSpecificPrimitives .contains (r .baseType ))
734
739
imports .add (r .baseType );
735
-
736
- if (response == methodResponse )
737
- methodCodegenResponse = r ;
740
+ r .isDefault = response == methodResponse ;
738
741
op .responses .add (r );
739
742
}
740
743
op .responses .get (op .responses .size () - 1 ).hasMore = false ;
@@ -918,6 +921,19 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
918
921
collectionFormat = qp .getCollectionFormat ();
919
922
CodegenProperty pr = fromProperty ("inner" , inner );
920
923
p .baseType = pr .datatype ;
924
+ p .isContainer = true ;
925
+ imports .add (pr .baseType );
926
+ }
927
+ else if ("object" .equals (qp .getType ())) {
928
+ Property inner = qp .getItems ();
929
+ if (inner == null ) {
930
+ LOGGER .warn ("warning! No inner type supplied for map parameter \" " + qp .getName () + "\" , using String" );
931
+ inner = new StringProperty ().description ("//TODO automatically added by swagger-codegen" );
932
+ }
933
+ property = new MapProperty (inner );
934
+ collectionFormat = qp .getCollectionFormat ();
935
+ CodegenProperty pr = fromProperty ("inner" , inner );
936
+ p .baseType = pr .datatype ;
921
937
imports .add (pr .baseType );
922
938
}
923
939
else
@@ -926,6 +942,7 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
926
942
LOGGER .warn ("warning! Property type \" " + qp .getType () + "\" not found for parameter \" " + param .getName () + "\" , using String" );
927
943
property = new StringProperty ().description ("//TODO automatically added by swagger-codegen. Type was " + qp .getType () + " but not supported" );
928
944
}
945
+ property .setRequired (param .getRequired ());
929
946
CodegenProperty model = fromProperty (qp .getName (), property );
930
947
p .collectionFormat = collectionFormat ;
931
948
p .dataType = model .datatype ;
@@ -949,6 +966,7 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
949
966
else {
950
967
// TODO: missing format, so this will not always work
951
968
Property prop = PropertyBuilder .build (impl .getType (), null , null );
969
+ prop .setRequired (bp .getRequired ());
952
970
CodegenProperty cp = fromProperty ("property" , prop );
953
971
if (cp != null ) {
954
972
p .dataType = cp .datatype ;
@@ -962,6 +980,7 @@ else if(model instanceof ArrayModel) {
962
980
CodegenModel cm = fromModel (bp .getName (), impl );
963
981
// get the single property
964
982
ArrayProperty ap = new ArrayProperty ().items (impl .getItems ());
983
+ ap .setRequired (param .getRequired ());
965
984
CodegenProperty cp = fromProperty ("inner" , ap );
966
985
if (cp .complexType != null ) {
967
986
imports .add (cp .complexType );
0 commit comments