@@ -2934,7 +2934,8 @@ public CodegenModel fromModel(String name, Schema schema) {
29342934 m .setFormat (schema .getFormat ());
29352935 m .setComposedSchemas (getComposedSchemas (schema ));
29362936 if (ModelUtils .isArraySchema (schema )) {
2937- CodegenProperty arrayProperty = fromProperty (name , schema , false );
2937+ String itemName = getItemsNameForModel (name );
2938+ CodegenProperty arrayProperty = fromProperty (itemName , schema , false );
29382939 m .setItems (arrayProperty .items );
29392940 m .arrayModelType = arrayProperty .complexType ;
29402941 addParentContainer (m , name , schema );
@@ -3032,17 +3033,17 @@ protected void setAddProps(Schema schema, IJsonSchemaValidationProperties proper
30323033 if (schema .getAdditionalProperties () == null ) {
30333034 if (!disallowAdditionalPropertiesIfNotPresent ) {
30343035 isAdditionalPropertiesTrue = true ;
3035- addPropProp = fromProperty ("" , new Schema (), false );
3036+ addPropProp = fromProperty (getAdditionalPropertiesName () , new Schema (), false );
30363037 additionalPropertiesIsAnyType = true ;
30373038 }
30383039 } else if (schema .getAdditionalProperties () instanceof Boolean ) {
30393040 if (Boolean .TRUE .equals (schema .getAdditionalProperties ())) {
30403041 isAdditionalPropertiesTrue = true ;
3041- addPropProp = fromProperty ("" , new Schema (), false );
3042+ addPropProp = fromProperty (getAdditionalPropertiesName () , new Schema (), false );
30423043 additionalPropertiesIsAnyType = true ;
30433044 }
30443045 } else {
3045- addPropProp = fromProperty ("" , (Schema ) schema .getAdditionalProperties (), false );
3046+ addPropProp = fromProperty (getAdditionalPropertiesName () , (Schema ) schema .getAdditionalProperties (), false );
30463047 if (ModelUtils .isAnyType ((Schema ) schema .getAdditionalProperties ())) {
30473048 additionalPropertiesIsAnyType = true ;
30483049 }
@@ -3850,13 +3851,7 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
38503851 }
38513852
38523853 // handle inner property
3853- String itemName = null ;
3854- if (p .getExtensions () != null && p .getExtensions ().get ("x-item-name" ) != null ) {
3855- itemName = p .getExtensions ().get ("x-item-name" ).toString ();
3856- }
3857- if (itemName == null ) {
3858- itemName = property .name ;
3859- }
3854+ String itemName = getItemsNameForProp (p , name );
38603855 ArraySchema arraySchema = (ArraySchema ) p ;
38613856 Schema innerSchema = unaliasSchema (getSchemaItems (arraySchema ));
38623857 CodegenProperty cp = fromProperty (itemName , innerSchema , false );
@@ -7914,6 +7909,27 @@ public List<VendorExtension> getSupportedVendorExtensions() {
79147909 */
79157910 protected String handleSpecialCharacters (String name ) { return name ; }
79167911
7912+ public String getItemsNameForProp (Schema containingSchema , String containingSchemaName ) {
7913+ String itemName = null ;
7914+ if (containingSchema .getExtensions () != null && containingSchema .getExtensions ().get ("x-item-name" ) != null ) {
7915+ itemName = containingSchema .getExtensions ().get ("x-item-name" ).toString ();
7916+ }
7917+ if (itemName == null ) {
7918+ itemName = toVarName (containingSchemaName );
7919+ }
7920+ return itemName ;
7921+ }
7922+
7923+ public String getItemsNameForModel (String containingSchemaName ) {
7924+ return containingSchemaName ;
7925+ }
7926+
7927+
7928+ public String getAdditionalPropertiesName () {
7929+ return "additional_properties" ;
7930+ }
7931+
7932+
79177933 /**
79187934 * Used to ensure that null or Schema is returned given an input Boolean/Schema/null
79197935 * This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas
0 commit comments