Skip to content

ArkType string.date breaks OpenAPI schema generation #1844

Description

@Umbrien

What version of Elysia is running?

1.4.28

What platform is your computer?

Darwin 25.3.0 arm64 arm

What environment are you using

1.3.9

Are you using dynamic mode?

No

What steps can reproduce the bug?

Create an Elysia app using @elysiajs/openapi and define a request body using ArkType with a string.date field. Then start the server and open /openapi route.

Minimal reproduction:

import { Elysia, t } from "elysia";
import { openapi } from "@elysiajs/openapi";
import { type } from "arktype";

const app = new Elysia()
  .use(openapi())
  .post(
    "/bug",
    () => {
      ok: true;
    },
    {
      body: type({
        date: "string.date",
      }),
    },
  )
  .listen(3000);

Run the app → OpenAPI generation fails with an error.

For comparison, this works correctly:

.post(
  "/non-bug",
  () => {
    ok: true;
  },
  {
    body: t.Object({
      date: t.String({ format: "date-time" }),
    }),
  },
)

What is the expected behavior?

OpenAPI schema should be generated successfully.
The string.date field should be translated into a valid JSON Schema representation and have same description as in typebox case: "the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z"

What do you see instead?

OpenAPI generation crashes with:

ToJsonSchemaError: {
    code: "predicate",
    base: {
        type: "string"
    },
    predicate: Function(isParsableDate)
}
 context: {
  code: "predicate",
  base: [Object ...],
  predicate: [Function: isParsableDate],
},
    code: "predicate"

      at throw (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@ark/schema/out/shared/toJsonSchema.js:36:15)
      at reduce (1:11)
      at toResolvedJsonSchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@ark/schema/out/roots/root.js:102:29)
      at reduceObjectJsonSchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@ark/schema/out/structure/structure.js:560:48)
      at reduce (1:11)
      at toResolvedJsonSchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@ark/schema/out/roots/root.js:102:29)
      at toJsonSchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@ark/schema/out/roots/root.js:75:36)
      at unwrapSchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@elysiajs/openapi/dist/index.mjs:2973:59)
      at toOpenAPISchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@elysiajs/openapi/dist/index.mjs:3198:20)
      at openAPISchema (/Users/umbrien/CodeProjects/date-openapi-bug/node_modules/@elysiajs/openapi/dist/index.mjs:10258:9)

Additional information

Minimal reproduction repo: https://github.com/Umbrien/elysia-arktype-date-openapi-bug-report

Have you try removing the node_modules and bun.lockb and try again yet?

No

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions