@glyphp/adapter-openapi
v1.0.1
Published
Convert an OpenAPI 3.x document into registerable Glyph Protocol glyphs
Maintainers
Readme
@glyphp/adapter-openapi
Converts an OpenAPI 3.x document into glyphs — one per operation — that you can
register on a GlyphServer.
import { glyphsFromOpenApi } from '@glyphp/adapter-openapi'
import { GlyphServer } from '@glyphp/server'
const doc = await fetch('https://api.example.com/openapi.json').then((r) => r.json())
const glyphs = glyphsFromOpenApi(doc, { baseUrl: 'https://api.example.com' })
const server = new GlyphServer({ port: 3100 })
for (const glyph of glyphs) server.register(glyph)
await server.start()Each generated glyph:
- takes its
namefromoperationId(kebab-cased),intentfromsummary - derives
costfrom the HTTP method — GET issafe, POST/PUT/PATCH arecaution, DELETE isdangerand requires confirmation - carries the operation's parameter and response JSON Schemas (local
$refs resolved) as the cardinput/output - has a handler that proxies the call to the real REST endpoint: path
parameters are substituted, query parameters appended, and the
bodyinput field sent as a JSON request body
Header and cookie parameters are not mapped in this version.
