Skip to content

feat(management): endpoint schemas + facilitator/x402Version on createApi#8

Open
TheRealAlexandre wants to merge 3 commits into
web3luka:mainfrom
TheRealAlexandre:feat/management-endpoint-schemas
Open

feat(management): endpoint schemas + facilitator/x402Version on createApi#8
TheRealAlexandre wants to merge 3 commits into
web3luka:mainfrom
TheRealAlexandre:feat/management-endpoint-schemas

Conversation

@TheRealAlexandre

@TheRealAlexandre TheRealAlexandre commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fill in the remaining gaps in the Management API TypeScript types so every field the server already accepts is reachable from the SDK — and APIs created through the SDK show up in the marketplace with fully populated test forms.

1. Endpoint schemas (commit a39dc09)

Without schema info, the marketplace Test tab renders no inputs. Callers now have three ergonomic options (any one is enough):

  • Per-endpoint parameters — OpenAPI Parameter Objects (query / path / header), with full field preservation (schema, style, example, deprecated, ...).
  • Per-endpoint requestBody — full OpenAPI shape ({ content: { 'application/json': { schema } } }) or simplified inner-schema shape ({ required: [...], properties: {...} }).
  • Top-level openApi on CreateApiInput — pass a full OpenAPI 3.x document (object or JSON string). If endpoints is omitted, endpoints are derived from the spec's paths with a default price.

New types: OpenApiParameter, OpenApiRequestBody.

2. Facilitator & x402Version (commit ba85de1)

facilitator and x402Version were accepted server-side but not typed. Expose them on CreateApiInput, export a Facilitator union (with a (string & {}) escape hatch so new facilitators don't break builds) and an X402Version = 1 | 2 alias. Server still validates the (facilitator, network, version) triple against its support matrix.

No breaking changes — every new field is optional.

Usage

await mgmt.createApi({
  name, baseUrl, merchantWallet,
  network: 'base',
  facilitator: 'payai',
  x402Version: 2,
  endpoints: [
    {
      path: '/v1/search',
      method: 'get',
      usdPrice: 0.05,
      parameters: [
        { name: 'q', in: 'query', required: true, description: 'Search query' },
        { name: 'limit', in: 'query', schema: { type: 'integer' } },
      ],
    },
    {
      path: '/v1/predict',
      method: 'post',
      usdPrice: 0.10,
      requestBody: {
        required: ['prompt'],
        properties: {
          prompt: { type: 'string' },
          temperature: { type: 'number', minimum: 0, maximum: 1 },
        },
      },
    },
  ],
});

// Alternative — pass a full OpenAPI spec:
await mgmt.createApi({
  name, baseUrl, merchantWallet, network: 'base',
  openApi: require('./my-openapi.json'),
});

Test plan

  • npx tsc --noEmit passes (verified).
  • Per-endpoint parameters renders query inputs on the marketplace test tab.
  • Per-endpoint requestBody (simplified shape) renders the body form.
  • Full openApi spec — endpoints auto-derived, schemas available.
  • facilitator: 'relai' with network: 'skale-base' accepted; facilitator: 'dexter' with network: 'skale-base' rejected with 400.
  • Omitting all new fields is still accepted (backwards-compatible).

Extend CreateApiInput and ApiEndpointInput so callers can describe each
endpoint's query/path/header parameters and request body schema — or pass a
full OpenAPI 3.x spec via the new `openApi` field. Without this, APIs created
through the Management API appear in the marketplace with no testable inputs
because the UI has no schema to render.
Expose optional facilitator and x402Version fields on CreateApiInput (already
accepted server-side) so TypeScript callers can pick the settlement
facilitator per API. Defaults to the first supported facilitator on the
network and the newest x402 version the pair supports. Server rejects
unsupported (facilitator, network, version) triples.
@TheRealAlexandre TheRealAlexandre changed the title feat(management): accept OpenAPI parameters, requestBody, or full spec feat(management): endpoint schemas + facilitator/x402Version on createApi Apr 16, 2026
Reflect the server-side default resolution: createApi without an explicit
facilitator uses relai whenever the network supports it (every network
except peaq and sei) and x402Version defaults to 2 wherever the pair
supports v2. No code change — JSDoc only.
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.

1 participant