Skip to content

[Request]: Adopt standard schemas and OpenAPI for provider interoperability #845

Closed

Description

@jimhoyd

Problem or use case

#841's executed probes show request.body.schema rejects $schema, $defs, nullable type arrays and anyOf. Body, store and forms have separate vocabularies; extension config already uses Ajv. This prevents straightforward reuse of standard documents and makes agents learn multiple schemas. These are documented limits, not undisclosed parser defects.

Proposed behavior and alternatives

Select an explicit JSON Schema dialect and bounded target support profile, with OpenAPI 3.1 exchange for known HTTP operations. Use mature validators rather than expanding a private general-purpose validator. Inert documents must stay inert. Standard Schema/Standard JSON Schema may be accepted at trusted TypeScript provider boundaries; validation and conversion functions execute trusted code and are not imported by passive inspection.

First deliverable: export a known sample API and consume one independently authored standard schema with local refs. Reuse provider-owned OpenAPI where complete and verified. State unknown handler response shapes or opaque mount paths instead of inventing schemas. Preserve operator-only configuration outside the public API description and explicitly attach URLCode authority/target facts through a namespaced extension or companion manifest.

Do not promise arbitrary OpenAPI import or automatic remote-API-to-MCP exposure. Do not put connection/authentication secrets in schema artifacts. GET/POST on the same declared application path must be expressible/reviewable in the new chosen contract; do not reproduce #842's unsupported rewrite advice.

Acceptance:

  • Object, nullable/union, local-ref and invalid-input fixtures pass the chosen validator. Unsupported keywords/refs/targets fail explicitly with bounded diagnostics; no silent loss of constraints or implicit remote fetch.
  • One source schema supplies HTTP and a declared MCP operation and can inform a form without conflating display metadata, transport coercion, DB defaults or authorization.
  • OpenAPI output validates with an independent standard tool, supports a generated client and one contract-testing run. Auth cookies/secrets and provider admin-only APIs are excluded or explicitly scoped.
  • Choose runtime-specific validation only behind shared behavioral fixtures. The prior Ajv probe passed CJS with a runtime helper but raw ESM failed; do not claim Worker/no-eval compatibility until the bundled output runs on that target. SDK-provided validator facilities are another candidate where they fit.
  • Test schema resource limits, regex admission, diagnostic redaction, absent/null semantics and identity-before-mutation ordering.
  • Remove superseded private validation paths and handwritten schema copies once the chosen new contract passes. No old-dialect translator or compatibility modes.

Node is the first integrated provider target. Other existing runtime targets retain their supported behavior; new unsupported schema/provider capabilities refuse before serving. Sandbox isolation does not change. Forward SQL schema initialization is still needed; historical application data migration is outside this work.

Implementation areas: body-schema.ts, http-policy.ts, manifest.ts, schema/query tooling, packages/mcp, store/forms contracts as selected, authoritative docs and executable fixtures. Keep schema edits generated through docs:reference, and semantic changes synchronized with RUNTIME-IMPLEMENTATION.md. Coordinate with #835 and #834 rather than duplicate their work.

Primary sources: https://json-schema.org/draft/2020-12 ; https://standardschema.dev/ ; https://spec.openapis.org/oas/v3.1.1.html ; https://ajv.js.org/standalone.html ; https://ts.sdk.modelcontextprotocol.io/v2/advanced/schema-libraries . This issue selects/contracts a target profile, not mandatory support for every feature of those standards.

Activity

  1. jimhoyd commented on Sep 28, 2026

    @jimhoyd
    CollaboratorAuthor

    One observation from the #843 proof (PR: #848): /api/requests serves GET (list, with a declared status query enum) and POST (create, JSON body schema) on one path, as the specification directs. request.body.required is route-wide, so the POST's "a body is required" rule cannot be declared without breaking GET; the handler checks it (400 body_required). Worth covering when the chosen OpenAPI-shaped contract describes per-operation request bodies on one path.

  2. jimhoyd commented on Sep 29, 2026

    @jimhoyd
    CollaboratorAuthor

    Owner decision (2026-09-29): the auth mount stays opaque in the OpenAPI export. Sign-in is Better Auth's own API, used through its official client, so we won't import Better Auth's generated description. Named project schemas shared by HTTP and MCP, and schema files with offline relative refs, are in #907.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions