Array-type schemas do not behave as arrays in generated models #460 #510

Open
opened 2026-03-05 09:29:08 +01:00 by mortega · 0 comments

When a schema is declared with type: array, the generated class does not extend from ArrayList, which means it cannot be used as an array.

# ...omitted
components:
  schemas:
    type: array
      items:
        type: string

In version 3.x, this worked correctly: the generated model extended its parent type and behaved as expected.

After analyzing the code, I found that the issue is related to the interfaceModels property, which is empty when the schema type is array. Additionally, the current template no longer extends from the parent type, unlike previous versions where this was done explicitly.

When a schema is declared with `type: array`, the generated class does not extend from ArrayList, which means it cannot be used as an array. ```yaml # ...omitted components: schemas: type: array items: type: string ``` In version 3.x, this worked correctly: the generated model extended its parent type and behaved as expected. After analyzing the code, I found that the issue is related to the `interfaceModels` property, which is empty when the schema type is array. Additionally, [the current template](https://git.kokuwa.io/kokuwaio/micronaut-openapi-codegen/src/branch/main/src/main/resources/Micronaut/modelPojo.mustache#L6) no longer extends from the parent type, unlike [previous versions](https://git.kokuwa.io/kokuwaio/micronaut-openapi-codegen/src/branch/3.x/src/main/resources/Micronaut/modelPojo.mustache#L9) where this was done explicitly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
kokuwaio/micronaut-openapi-codegen#510
No description provided.