Skip to content

Conversation

@stevedylandev
Copy link
Contributor

@stevedylandev stevedylandev commented Dec 2, 2025

This PR starts implementation of hono-openapi to complete #1115. Work includes:

  • Installing hono-openapi
  • Updates validate.ts to use validator from hono-openapi
  • Adds response zod schemas to ensnode-sdk
  • Adds describeRoute to resolution endpoints
  • Adds GET /openapi.json route

The result is an OpenAPI schema that can be fetched from /openapi.json from the ENSApi:

curl http://localhost:4334/openapi.json | jq . 

With the schema we can build new documentation that accepts OpenAPI for automatic API references. At least for the API we can write almost all of the documentation inside the routes themselves. Here is an example:

app.get(
  "/records/:name",
  describeRoute({
    summary: "Resolve ENS Records",
    description: `Resolves ENS records for a given name, including addresses, text records, and other metadata.

## Query Parameters

- \`addresses\` - Comma-separated list of coin type IDs (e.g., \`60\` for ETH, \`0\` for BTC)
- \`texts\` - Comma-separated list of text record keys (e.g., \`avatar\`, \`com.twitter\`)
- \`name\` - Set to \`true\` to include name resolution
- \`trace\` - Set to \`true\` to include resolution trace information
- \`accelerate\` - Set to \`true\` to attempt real-time acceleration

## Examples

### Resolve address records (ETH and BTC)
\`\`\`
GET /records/example.eth?addresses=60,0
\`\`\`

### Resolve text records (avatar and Twitter)
\`\`\`
GET /records/example.eth?texts=avatar,com.twitter
\`\`\`

### Combined resolution
\`\`\`
GET /records/example.eth?name=true&addresses=60,0&texts=avatar,com.twitter
\`\`\``,
    responses: {
      200: {
        description: "Successfully resolved records",
        content: {
          "application/json": {
            schema: resolver(makeResolveRecordsResponseSchema()),
          },
        },
      },
    },
  }),

Note

I don't like escaping characters in the mark up so I will be looking into another way to do this

This results in a docs page like this:

CleanShot 2025-12-02 at 10 08 51@2x

Take a look at the current preview built in a separate repo: https://docs-sepia-eight.vercel.app/docs/getApiResolveRecords

- Installs `hono-openapi`
- Updates `validate.ts` to use `validator` from `hono-openapi`
- Adds response zod schemas to ensnode-sdk
- Adds `describeRoute` to resolution endpoints
- Adds `GET /openapi.json` route
@stevedylandev stevedylandev requested a review from a team as a code owner December 2, 2025 14:52
@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2025

⚠️ No Changeset found

Latest commit: f91a9f8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Dec 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Dec 23, 2025 9:51pm
ensnode.io Ready Ready Preview, Comment Dec 23, 2025 9:51pm
ensrainbow.io Ready Ready Preview, Comment Dec 23, 2025 9:51pm

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevedylandev This looks like an exciting direction to me. Appreciate your advice on next steps 👍

The Hono OpenAPI implementation with Zod produces a JSON schema where
`z.undefined()` is
[unrepresentable](https://zod.dev/json-schema#unrepresentable). This
commit refactors the `NameTokensRequest` type and by consequence update
the zod schema to pass. In order for OpenAPI JSON schema to work we
cannot have any instances of unrepresentable APIs, and this so far was
the only case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants