@nest-openapi/runtime
v0.1.3
Published
<p align="center"> <img src="https://raw.githubusercontent.com/ts-oas/nest-openapi/main/docs/public/nest-openapi-logo.png" alt="nest-openapi-logo" height="80" /> </p>
Readme
Overview
@nest-openapi/runtime is the shared foundational library powering @nest-openapi/validator, @nest-openapi/serializer, @nest-openapi/mock, and @nest-openapi/mcp.
- Spec-driven core — Single source of truth spec loading from objects, files, and URLs.
- Runtime pooling — Centralized
OpenAPIRuntimePoolavoids redundant spec parsing across modules. - Platform-agnostic — Uniform request data extraction across Express and Fastify via
PlatformUtil. - Operation & Path resolution — Bidirectional path mapping and operation resolution.
Install
npm i @nest-openapi/runtimeKey Utilities
PlatformUtil
Extract request data identically across Express and Fastify:
import { PlatformUtil, type HttpArgumentsHost } from "@nest-openapi/runtime";
function handleRequest(ctx: HttpArgumentsHost) {
const { method, path, body, params, query } =
PlatformUtil.extractRequestData(ctx);
}OpenAPIRuntimeService
Load and access parsed OpenAPI specifications:
import { OpenAPIRuntimeService } from "@nest-openapi/runtime";
const runtime = new OpenAPIRuntimeService({
specSource: { type: "file", path: "./openapi.json" },
});
await runtime.init();
const spec = runtime.spec;Next Steps
- Validator — Spec-driven request and response validation
- Serializer — High-performance response serialization
- Mock — Spec-driven mock server utilities
- MCP — Exposing OpenAPI operations as MCP tools
