@@ -1578,36 +1578,62 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
1578
1578
codegenProperty .name = toVarName (name );
1579
1579
codegenProperty .baseName = name ;
1580
1580
codegenProperty .nameInCamelCase = camelize (codegenProperty .name , false );
1581
- codegenProperty .description = escapeText (propertySchema .getDescription ());
1582
- codegenProperty .unescapedDescription = propertySchema .getDescription ();
1583
- codegenProperty .title = propertySchema .getTitle ();
1584
1581
codegenProperty .getter = toGetter (name );
1585
1582
codegenProperty .setter = toSetter (name );
1586
- String example = toExampleValue (propertySchema );
1583
+ setSchemaProperties (name , codegenProperty , propertySchema );
1584
+
1585
+ final String type = getSchemaType (propertySchema );
1586
+
1587
+ processPropertySchemaTypes (name , codegenProperty , propertySchema );
1588
+
1589
+ codegenProperty .datatype = getTypeDeclaration (propertySchema );
1590
+ codegenProperty .dataFormat = propertySchema .getFormat ();
1591
+
1592
+ // this can cause issues for clients which don't support enums
1593
+ boolean isEnum = getBooleanValue (codegenProperty , IS_ENUM_EXT_NAME );
1594
+ if (isEnum ) {
1595
+ codegenProperty .datatypeWithEnum = toEnumName (codegenProperty );
1596
+ codegenProperty .enumName = toEnumName (codegenProperty );
1597
+ } else {
1598
+ codegenProperty .datatypeWithEnum = codegenProperty .datatype ;
1599
+ }
1600
+
1601
+ codegenProperty .baseType = getSchemaType (propertySchema );
1602
+
1603
+ processPropertySchemaContainerTypes (codegenProperty , propertySchema , type );
1604
+ return codegenProperty ;
1605
+ }
1606
+
1607
+ protected void setSchemaProperties (String name , CodegenProperty codegenProperty , Schema schema ) {
1608
+ codegenProperty .description = escapeText (schema .getDescription ());
1609
+ codegenProperty .unescapedDescription = schema .getDescription ();
1610
+ codegenProperty .title = schema .getTitle ();
1611
+ String example = toExampleValue (schema );
1587
1612
if (!"null" .equals (example )) {
1588
1613
codegenProperty .example = example ;
1589
1614
}
1590
- codegenProperty .defaultValue = toDefaultValue (propertySchema );
1591
- codegenProperty .defaultValueWithParam = toDefaultValueWithParam (name , propertySchema );
1592
- codegenProperty .jsonSchema = Json .pretty (propertySchema );
1593
- codegenProperty .nullable = Boolean .TRUE .equals (propertySchema .getNullable ());
1594
- codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_NULLABLE_EXT_NAME , Boolean .TRUE .equals (propertySchema .getNullable ()));
1595
- if (propertySchema .getReadOnly () != null ) {
1596
- codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_READ_ONLY_EXT_NAME , propertySchema .getReadOnly ());
1597
- }
1598
- if (propertySchema .getXml () != null ) {
1599
- if (propertySchema .getXml ().getAttribute () != null ) {
1600
- codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_XML_ATTRIBUTE_EXT_NAME , propertySchema .getXml ().getAttribute ());
1615
+ codegenProperty .defaultValue = toDefaultValue (schema );
1616
+ codegenProperty .defaultValueWithParam = toDefaultValueWithParam (name , schema );
1617
+ codegenProperty .jsonSchema = Json .pretty (schema );
1618
+ codegenProperty .nullable = Boolean .TRUE .equals (schema .getNullable ());
1619
+ codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_NULLABLE_EXT_NAME , Boolean .TRUE .equals (schema .getNullable ()));
1620
+ if (schema .getReadOnly () != null ) {
1621
+ codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_READ_ONLY_EXT_NAME , schema .getReadOnly ());
1622
+ }
1623
+ if (schema .getXml () != null ) {
1624
+ if (schema .getXml ().getAttribute () != null ) {
1625
+ codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_XML_ATTRIBUTE_EXT_NAME , schema .getXml ().getAttribute ());
1601
1626
}
1602
- codegenProperty .xmlPrefix = propertySchema .getXml ().getPrefix ();
1603
- codegenProperty .xmlName = propertySchema .getXml ().getName ();
1604
- codegenProperty .xmlNamespace = propertySchema .getXml ().getNamespace ();
1627
+ codegenProperty .xmlPrefix = schema .getXml ().getPrefix ();
1628
+ codegenProperty .xmlName = schema .getXml ().getName ();
1629
+ codegenProperty .xmlNamespace = schema .getXml ().getNamespace ();
1605
1630
}
1606
- if (propertySchema .getExtensions () != null && !propertySchema .getExtensions ().isEmpty ()) {
1607
- codegenProperty .getVendorExtensions ().putAll (propertySchema .getExtensions ());
1631
+ if (schema .getExtensions () != null && !schema .getExtensions ().isEmpty ()) {
1632
+ codegenProperty .getVendorExtensions ().putAll (schema .getExtensions ());
1608
1633
}
1634
+ }
1609
1635
1610
- final String type = getSchemaType ( propertySchema );
1636
+ protected void processPropertySchemaTypes ( String name , CodegenProperty codegenProperty , Schema propertySchema ) {
1611
1637
if (propertySchema instanceof IntegerSchema ) {
1612
1638
codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_NUMERIC_EXT_NAME , Boolean .TRUE );
1613
1639
if (SchemaTypeUtil .INTEGER64_FORMAT .equals (propertySchema .getFormat ())) {
@@ -1644,7 +1670,6 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
1644
1670
codegenProperty .allowableValues = allowableValues ;
1645
1671
}
1646
1672
}
1647
-
1648
1673
if (propertySchema instanceof StringSchema ) {
1649
1674
codegenProperty .maxLength = propertySchema .getMaxLength ();
1650
1675
codegenProperty .minLength = propertySchema .getMinLength ();
@@ -1715,20 +1740,9 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
1715
1740
codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_DATE_TIME_EXT_NAME , Boolean .TRUE );
1716
1741
handlePropertySchema (propertySchema , codegenProperty );
1717
1742
}
1718
- codegenProperty .datatype = getTypeDeclaration (propertySchema );
1719
- codegenProperty .dataFormat = propertySchema .getFormat ();
1720
-
1721
- // this can cause issues for clients which don't support enums
1722
- boolean isEnum = getBooleanValue (codegenProperty , IS_ENUM_EXT_NAME );
1723
- if (isEnum ) {
1724
- codegenProperty .datatypeWithEnum = toEnumName (codegenProperty );
1725
- codegenProperty .enumName = toEnumName (codegenProperty );
1726
- } else {
1727
- codegenProperty .datatypeWithEnum = codegenProperty .datatype ;
1728
- }
1729
-
1730
- codegenProperty .baseType = getSchemaType (propertySchema );
1743
+ }
1731
1744
1745
+ protected void processPropertySchemaContainerTypes (CodegenProperty codegenProperty , Schema propertySchema , String type ) {
1732
1746
if (propertySchema instanceof ArraySchema ) {
1733
1747
codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_CONTAINER_EXT_NAME , Boolean .TRUE );
1734
1748
codegenProperty .getVendorExtensions ().put (CodegenConstants .IS_LIST_CONTAINER_EXT_NAME , Boolean .TRUE );
@@ -1784,7 +1798,6 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
1784
1798
}
1785
1799
setNonArrayMapProperty (codegenProperty , type );
1786
1800
}
1787
- return codegenProperty ;
1788
1801
}
1789
1802
1790
1803
private void handleMinMaxValues (Schema propertySchema , CodegenProperty codegenProperty ) {
0 commit comments