Bug Report Checklist
Description
OpenAPI generator fails to generate array models. It complains with:
[main] INFO o.o.codegen.DefaultGenerator - Model {} not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)
openapi-generator version
v4.3.1
And also tried latest master using Docker 07c23f4.
OpenAPI declaration file content or url
openapi: '3.0.3'
info:
title: Test
version: 0.1.0
paths: {}
components:
schemas:
Test:
type: array
items:
type: object
properties:
foo:
type: string
Generation Details
docker run --rm \
-v ${PWD}:/local openapitools/openapi-generator-cli generate \
-i /local/openapi.yaml \
-g go \
-o /local/out/go
Steps to reproduce
- Generate a client for any language using the provided schema. Note that the array model is not generated with the log message from this bug's description.
Related issues/PRs
Suggest a fix
The following code is erroneous. An array has items not properties (Even required by the OpenAPI spec). You might need to cast Schema to ArraySchema to get access to items or something like that.
|
if (!ModelUtils.isGenerateAliasAsModel(schema) && (schema.getProperties() == null || schema.getProperties().isEmpty())) { |
|
// schema without property, i.e. alias to array |
|
LOGGER.info("Model {} not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)", name); |
|
continue; |
Bug Report Checklist
Description
OpenAPI generator fails to generate array models. It complains with:
openapi-generator version
v4.3.1
And also tried latest master using Docker 07c23f4.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
The following code is erroneous. An array has
itemsnotproperties(Even required by the OpenAPI spec). You might need to castSchematoArraySchemato get access to items or something like that.openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java
Lines 485 to 488 in 41851b4