File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -328,7 +328,20 @@ public String getTypeDeclaration(Schema p) {
328328 if (ModelUtils .isArraySchema (p )) {
329329 ArraySchema ap = (ArraySchema ) p ;
330330 Schema inner = ap .getItems ();
331- return "[]" + getTypeDeclaration (ModelUtils .unaliasSchema (this .openAPI , inner ));
331+ // In OAS 3.0.x, the array "items" attribute is required.
332+ // In OAS >= 3.1, the array "items" attribute is optional such that the OAS
333+ // specification is aligned with the JSON schema specification.
334+ // When "items" is not specified, the elements of the array may be anything at all.
335+ if (inner != null ) {
336+ inner = ModelUtils .unaliasSchema (this .openAPI , inner );
337+ }
338+ String typDecl ;
339+ if (inner != null ) {
340+ typDecl = getTypeDeclaration (inner );
341+ } else {
342+ typDecl = "interface{}" ;
343+ }
344+ return "[]" + typDecl ;
332345 } else if (ModelUtils .isMapSchema (p )) {
333346 Schema inner = ModelUtils .getAdditionalProperties (p );
334347 return getSchemaType (p ) + "[string]" + getTypeDeclaration (ModelUtils .unaliasSchema (this .openAPI , inner ));
You can’t perform that action at this time.
0 commit comments