← Public packages
@kody/openapi
Bind an OpenAPI spec and call selected operations with saved integration or secret names.
src/get.ts
33 lines · 1.0 KB · TypeScriptimport { assertBindingName, toOpenApiBindingSummary } from './selection.ts'
import { requireBinding } from './storage.ts'
/**
* Load one stored OpenAPI binding and its operation slugs.
* Use when you need method/path detail before call().
*
* @param input - Binding name
* @returns Summary plus the selected operations
*
* @example
* import get from 'kody:@<username>/openapi/get'
* const detail = await get({ name: 'acme' })
*/
export default async function get(input: { name: string }) {
const name = assertBindingName(input.name)
const binding = await requireBinding(name)
return {
binding: toOpenApiBindingSummary(binding),
operations: binding.operations.map((operation) => ({
slug: operation.slug,
operationId: operation.operationId,
method: operation.method,
path: operation.path,
summary: operation.summary,
deprecated: operation.deprecated,
tags: operation.tags,
})),
authKind: binding.auth.kind,
selection: binding.selection,
includeDestructive: binding.includeDestructive,
}
}