File tree 1 file changed +14
-1
lines changed
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -328,7 +328,20 @@ public String getTypeDeclaration(Schema p) {
328
328
if (ModelUtils .isArraySchema (p )) {
329
329
ArraySchema ap = (ArraySchema ) p ;
330
330
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 ;
332
345
} else if (ModelUtils .isMapSchema (p )) {
333
346
Schema inner = ModelUtils .getAdditionalProperties (p );
334
347
return getSchemaType (p ) + "[string]" + getTypeDeclaration (ModelUtils .unaliasSchema (this .openAPI , inner ));
You can’t perform that action at this time.
0 commit comments