elysiajs / elysia-swagger

A plugin for Elysia to auto-generate Swagger page
MIT License
90 stars 46 forks source link

Running into `Schemas with 'type: array', require a sibling 'items: ' field` error #28

Open nikhilro opened 1 year ago

nikhilro commented 1 year ago

Running into Schemas with 'type: array', require a sibling 'items: ' field error when validating the OpenAPI schema that's generated by the plugin.

// this is my endpoint
  .get("/", ({ store: { db }, orgId }) => getCustomers(db(), orgId), {
    response: t.Array(Customer),
  })

// this is the type
import { BaseDbModel } from "./baseTypes";
import { Static } from "@sinclair/typebox";
import { t } from "elysia";

export const CustomerParams = t.Object({
  number: t.Optional(t.Union([t.String(), t.Null()])),
});
export type CustomerParams = Static<typeof CustomerParams>;

export const Customer = t.Intersect([
  BaseDbModel,
  CustomerParams,
  t.Object({ orgId: t.String() }),
]);
export type Customer = Static<typeof Customer>;

Would appreciate any ideas!