Skip to content
Discussion options

You must be logged in to vote

In ArkType 2.2.8, pass "self" as the second argument to .describe(). The default selector is "shallow", which also reaches the union's branches; "self" changes only the union node's metadata.

import { type } from "arktype"

const FooEnum = type(['"one"', "@", "one"])
  .or(type(['"two"', "@", "two"]))

const Foo = type({
  bar: FooEnum.describe("Bar's description", "self")
})

console.log(Foo.toJsonSchema())

The bar property then contains:

{
  "anyOf": [
    { "const": "one", "description": "one" },
    { "const": "two", "description": "two" }
  ],
  "description": "Bar's description"
}

Tested on 2.2.8, including reproducing the branch-description overwrite without "self". This uses the c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gwennlbh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants