Releases: roebi/rxdb-openapi
v0.1.0
rxdb-openapi v0.1.0
Initial release — OpenAPI 3.1.0 plugin for RxDB Server.
RxDB Server's REST endpoint exposes 5 routes per collection but ships no OpenAPI spec.
rxdb-openapi generates one automatically from your collection schemas and serves it as
an Express-compatible middleware at GET /openapi.json.
Features
generateOpenApiSpec(options) — pure function, returns a complete OpenAPI 3.1.0 object.
No side effects, no runtime dependencies. Pass the result to any HTTP framework.
endpointFromCollection(name, collection) — extracts EndpointConfig from a live
RxCollection without importing rxdb at compile time (duck-typed interface).
createOpenApiMiddleware(options) — Express-compatible middleware.
Responds to GET /openapi.json and calls next() for all other paths.
generateOpenApiJson(options, pretty?) — returns the spec as a JSON string.
Use it to write openapi.json to disk or integrate with any custom server.
Generated routes per collection
Each addRestEndpoint({ name }) call produces 5 documented paths:
| Method | Path | Description |
|---|---|---|
POST |
/{name}/{version}/query |
Mango query — selector, sort, limit, skip |
GET |
/{name}/{version}/query/observe |
SSE stream of live query results |
POST |
/{name}/{version}/get |
Fetch documents by primary key |
POST |
/{name}/{version}/set |
Upsert documents |
POST |
/{name}/{version}/delete |
Delete documents by primary key |
RxDB internal fields (_deleted, _rev, _meta, _attachments) are merged into
every document schema automatically.
Quality
- 35 tests — Node.js built-in test runner (
node:test), zero extra test dependencies - Node 18 / 20 / 22 CI matrix
npm audit --omit=peer— 0 vulnerabilitiesrxdbandrxdb-serveraspeerDependenciesonly — not bundled
Install
npm install rxdb-openapiRequires Node.js >= 18. Peer deps: rxdb >= 15, rxdb-server >= 1.
Quick start
import { createOpenApiMiddleware, endpointFromCollection } from 'rxdb-openapi';
app.use(createOpenApiMiddleware({
title: 'My App API',
serverUrl: 'http://localhost:3000',
endpoints: [
endpointFromCollection('users', usersCollection)
]
}));
// GET http://localhost:3000/openapi.json → OpenAPI 3.1.0 JSONLinks
- npm: https://www.npmjs.com/package/rxdb-openapi
- Repository: https://github.com/roebi/rxdb-openapi
- RxDB Server docs: https://rxdb.info/rx-server.html