Skip to content

Array of response object in schema.yaml / schema.json does not result in array type in schema.d.ts #1421

Closed as not planned
@mklueh

Description

@mklueh

Description
Array type of response object does not result in array type in schema

 "SomeResponseObject" : {
        "type" : "object",
        "properties" : {
          "page" : {
            "format" : "int64",
            "type" : "integer"
          },
          "pages" : {
            "format" : "int64",
            "type" : "integer"
          },
          "items" : {
            "type" : "array",
            "items" : {
              "$ref" : "#/components/schemas/ResponseListItem"
            },
             "oneOf" : [ {
              "$ref" : "#/components/schemas/SomeItem"
            }, {
              "$ref" : "#/components/schemas/SomeOtherItem"
            } ]
          }
        }
      },

will result in

    SomeResponseObject: {
      /** Format: int64 */
      page?: number;
      /** Format: int64 */
      pages?: number;
      items?: components["schemas"]["SomeItem"] | components["schemas"]["SomeOtherItem"];
    };

Which does not represent the array but just a single item.

I've run Redocly and there are some issues, but nothing related to the object I'm referring to.

BTW the openapi.json / yaml is autogenerated by my Quarkus Application and this is the originating Java class:

@Data
@Builder
@AllArgsConstructor
public class SomeResponseObject {

    private long page;

    private long pages;

    @Schema(type = ARRAY, oneOf = {SomeItem.class, SomeOtherItem.class})
    private List<ResponseListItemDto> items;
}

I'm using

✨ openapi-typescript 6.7.0

Expected result

(in case it’s not obvious)

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript librarystale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions