Skip to content

feat(sdk): implement sdk metadata attachments#3923

Draft
SukkaW wants to merge 4 commits into
hey-api:mainfrom
SukkaW:sdk-method-schema
Draft

feat(sdk): implement sdk metadata attachments#3923
SukkaW wants to merge 4 commits into
hey-api:mainfrom
SukkaW:sdk-method-schema

Conversation

@SukkaW
Copy link
Copy Markdown
Contributor

@SukkaW SukkaW commented May 23, 2026

The PR fixes #3446 with metadata support.

When enabled, SDK operations are emitted via Object.assign(...) and expose OpenAPI-derived metadata such as:

  • id
  • method
  • url
  • tags
  • responseSchema

This works across SDK operation strategies:

  • flat
  • single
  • byTags

  • A metadata option is introduced to @hey-api/sdk with boolean or object form (granular control for schema output)
  • Changed v1 renderer to attach the metadata
  • Added tags metadata from OpenAPI operation tags.

This is a PoC kinda PR. Ideally, we might wanna implement the resolver API so that everyone can customize/tailor their own desired output shape here.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

@SukkaW is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 23, 2026

⚠️ No Changeset found

Latest commit: 28dcb6e

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 25.58140% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.70%. Comparing base (2702ce2) to head (8eda9d9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ges/openapi-ts/src/plugins/@hey-api/sdk/v1/node.ts 34.04% 25 Missing and 6 partials ⚠️
...api-ts/src/plugins/@hey-api/sdk/shared/metadata.ts 0.00% 17 Missing and 4 partials ⚠️
...pi-ts/src/plugins/@hey-api/sdk/shared/validator.ts 16.66% 3 Missing and 2 partials ⚠️
...ages/openapi-ts/src/plugins/@hey-api/sdk/config.ts 80.00% 0 Missing and 1 partial ⚠️
packages/openapi-ts/src/plugins/valibot/api.ts 0.00% 1 Missing ⚠️
packages/openapi-ts/src/plugins/valibot/v1/api.ts 0.00% 0 Missing and 1 partial ⚠️
packages/openapi-ts/src/plugins/zod/api.ts 0.00% 1 Missing ⚠️
packages/openapi-ts/src/plugins/zod/mini/api.ts 0.00% 0 Missing and 1 partial ⚠️
packages/openapi-ts/src/plugins/zod/v3/api.ts 0.00% 0 Missing and 1 partial ⚠️
packages/openapi-ts/src/plugins/zod/v4/api.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3923      +/-   ##
==========================================
- Coverage   37.75%   37.70%   -0.05%     
==========================================
  Files         582      583       +1     
  Lines       20817    20886      +69     
  Branches     6064     6096      +32     
==========================================
+ Hits         7859     7876      +17     
- Misses      10543    10578      +35     
- Partials     2415     2432      +17     
Flag Coverage Δ
unittests 37.70% <25.58%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@SukkaW SukkaW force-pushed the sdk-method-schema branch from 8eda9d9 to 28dcb6e Compare May 23, 2026 16:36
@SukkaW SukkaW marked this pull request as ready for review May 23, 2026 16:36
@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented May 23, 2026

Pullfrog stalled

The agent stopped emitting events for 305s and was killed by the activity-timeout watchdog. 91 events were processed before the failure.

Recent agent stderr
INFO  2026-05-23T16:43:56 +24ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +21ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +15ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +34ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +8ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +32ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +9ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +23ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +32ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +16ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +15ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +36ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +33ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +15ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +22ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +9ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +22ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +22ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +41ms service=bus type=message.part.delta publishing
INFO  2026-05-23T16:43:56 +207ms service=bus type=message.part.delta publishing

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using Kimi K2𝕏

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. feature 🚀 Feature request. labels May 23, 2026
@SukkaW SukkaW marked this pull request as draft May 23, 2026 16:37
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

ℹ️ Minor suggestions inline — otherwise clean implementation.

Reviewed changes — Added metadata option to @hey-api/sdk plugin that attaches OpenAPI-derived metadata to generated SDK operations via Object.assign(), with boolean or granular object configuration. Works across flat, single, and byTags strategies, and introduces request schema hoisting to avoid duplicate generation.

  • Add metadata config option — Boolean or UserMetadataConfig object with granular control over id, method, url, tags, requestSchema, responseSchema
  • Implement withMetadata wrapper — Uses Object.assign() to attach metadata properties to operation functions
  • Hoist request schemas — New createRequestSchema API on validator plugins (zod, valibot) allows reusing request schema nodes between metadata and request validators
  • Test coverage — Added 4 snapshot test scenarios: metadata-by-tags, metadata-flat, metadata-single, metadata-partial

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2𝕏

exampleIntent(method, operation, plugin);
if (isMetadataEnabled(plugin)) {
const field = attachComment({
node: $.field(createFnSymbol(plugin, item), (f) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
node: $.field(createFnSymbol(plugin, item), (f) =>
if (isMetadataEnabled(plugin)) {
const method = attachComment({
node: $.method(createFnSymbol(plugin, item), (m) =>
attachComment({
node: m,
operation,
plugin,
})
.public()
.static(!isAngularClient && !isInstance(plugin)),
).assign(
withMetadata({
fn: implementFn({
operation,
plugin,
requestSchema,
}),
operation,
plugin,
requestSchema,
tags,
}),
),
operation,
plugin,
});
node.do(method);
exampleIntent(method, operation, plugin);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pullfrog why

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot May 24, 2026

Choose a reason for hiding this comment

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

APIError: Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

ℹ️ No new issues found with the incremental changes.

Reviewed incremental changes — The author dropped requestSchema from the metadata object (commit 28dcb6e). Instead of hoisting request schemas as named constants and referencing them in both requestValidator and metadata, the validator now embeds the schema inline via z.object({...}).parseAsync(data) and the metadata no longer carries a requestSchema property.

  • Removes requestSchema from attached metadata — Simplifies the public API surface
  • Eliminates hoisted schema constants — Reverts the code reuse optimization that created shared zXxxData symbols
  • Regenerates all snapshot fixtures — Expected churn in __snapshots__/ directories

This addresses the concern that request schemas would bloat exports and leak internal zod details onto the operation metadata. The responseSchema reference remains in metadata, which is appropriate since response schemas are already emitted as named exports.

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2𝕏

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@SukkaW something happened here

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

Labels

feature 🚀 Feature request. size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attach additional metadata information on the sdk method

2 participants