{
  "$schema": "https://hyperjs.ai/schema/registry-item.json",
  "name": "openapi-valibot",
  "version": "0.1.0",
  "description": "SchemaConverter for Valibot to @hyper/openapi.",
  "readme": "# @hyper/openapi-valibot\n\nValibot `SchemaConverter` for `@hyper/openapi`.\n\n## Install\n\nComponents are installed as source into your repo, not pulled from npm. `valibot` is added to your `package.json` automatically as a peer dependency.\n\n```bash\nbunx hyper add openapi openapi-valibot\n```\n\n## Usage\n\n```ts\nimport { Hyper } from \"@hyper/core\"\nimport { openapiPlugin } from \"@hyper/openapi\"\nimport { valibotConverter } from \"@hyper/openapi-valibot\"\n\nexport default new Hyper()\n  .use(openapiPlugin({ converter: valibotConverter }))\n  .listen(3000)\n```\n\n## Docs\n\nSee the [main README](../../README.md) and [docs/](../../docs) for guides and integration recipes.\n\n## License\n\nMIT\n",
  "registryDeps": [
    "openapi"
  ],
  "peerDeps": {},
  "optionalPeerDeps": {},
  "files": [
    {
      "path": "openapi-valibot/index.ts",
      "contents": "/**\n * @hyper/openapi-valibot — SchemaConverter for Valibot schemas.\n *\n * Valibot schemas are plain objects with a `kind: \"schema\"` marker plus\n * `type` field (e.g. \"object\", \"string\", \"array\", \"union\", \"optional\").\n */\n\nimport type { JsonSchema, SchemaConverter } from \"@hyper/openapi\"\n\ninterface ValibotSchema {\n  readonly kind: \"schema\"\n  readonly type: string\n  readonly expects?: string\n  readonly [k: string]: unknown\n}\n\nfunction isValibot(s: unknown): s is ValibotSchema {\n  if (!s || typeof s !== \"object\") return false\n  const x = s as Record<string, unknown>\n  return x.kind === \"schema\" && typeof x.type === \"string\"\n}\n\nfunction toJson(v: ValibotSchema): JsonSchema {\n  switch (v.type) {\n    case \"string\":\n      return { type: \"string\" }\n    case \"number\":\n      return { type: \"number\" }\n    case \"boolean\":\n      return { type: \"boolean\" }\n    case \"literal\":\n      return { const: (v as { literal: unknown }).literal }\n    case \"picklist\":\n    case \"enum\":\n      return { enum: (v as { options: readonly unknown[] }).options }\n    case \"array\": {\n      const item = (v as { item: ValibotSchema }).item\n      return { type: \"array\", items: toJson(item) }\n    }\n    case \"object\": {\n      const entries = (v as { entries: Record<string, ValibotSchema> }).entries\n      const properties: Record<string, JsonSchema> = {}\n      const required: string[] = []\n      for (const [k, sub] of Object.entries(entries)) {\n        properties[k] = toJson(sub)\n        if (sub.type !== \"optional\" && sub.type !== \"nullish\") required.push(k)\n      }\n      return {\n        type: \"object\",\n        properties,\n        ...(required.length > 0 && { required }),\n      }\n    }\n    case \"optional\":\n    case \"nullish\":\n      return toJson((v as { wrapped: ValibotSchema }).wrapped)\n    case \"nullable\": {\n      const j = toJson((v as { wrapped: ValibotSchema }).wrapped)\n      const t = j.type\n      return { ...j, type: Array.isArray(t) ? [...t, \"null\"] : t ? [t as string, \"null\"] : \"null\" }\n    }\n    case \"union\": {\n      const opts = (v as { options: readonly ValibotSchema[] }).options\n      return { anyOf: opts.map(toJson) }\n    }\n    default:\n      return {}\n  }\n}\n\nexport const valibotConverter: SchemaConverter = {\n  name: \"valibot\",\n  canHandle: isValibot,\n  toJsonSchema: (s) => toJson(s as ValibotSchema),\n}\n",
      "sha256": "fdf64d870827b059368772bf9fad0f5d3406886c6a2e65e1b85fe86db5dfccf9"
    }
  ],
  "subpaths": {}
}