API

OpenAPI to Zod examples

Turn OpenAPI schemas into Zod validators and lightweight typed fetch clients.

User API components

OpenAPI 3 schemas with required fields, arrays, nullable fields, and formats.

{
  "openapi": "3.1.0",
  "info": {
    "title": "Users API",
    "version": "1.0.0"
  },
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "required": [
          "id",
          "email",
          "roles"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "admin",
                "editor",
                "viewer"
              ]
            }
          },
          "profile": {
            "$ref": "#/components/schemas/Profile"
          }
        }
      },
      "Profile": {
        "type": "object",
        "properties": {
          "website": {
            "type": "string",
            "format": "uri"
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}
Open example

Use these examples with guides