Skip to content

Commit 30aa5c1

Browse files
committed
Add OpenAPI/Swagger documentation for server integration
Updated server integration guide and CLI README to document automatic OpenAPI 3.0 spec generation and access URLs. This helps users import API definitions into Swagger UI, Postman, and similar tools for easier visualization and testing.
1 parent c3b4f1f commit 30aa5c1

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

docs/guide/server-integration.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ interface ObjectQLRequest {
7373
}
7474
```
7575

76+
## 📖 OpenAPI / Swagger Support
77+
78+
`@objectql/server` automatically generates an OpenAPI 3.0 specification from your registered schema.
79+
80+
You can access the spec by appending `/openapi.json` to your handler's mount path.
81+
82+
**Example URLs:**
83+
* **CLI Serve:** `http://localhost:3000/openapi.json`
84+
* **Express (mounted at /api/objectql):** `http://localhost:3000/api/objectql/openapi.json`
85+
* **Next.js (pages/api/objectql.ts):** `http://localhost:3000/api/objectql/openapi.json`
86+
87+
This JSON file describes your data objects as "Virtual REST" endpoints (`GET /user`, `POST /user`, etc.), allowing you to easily import them into **Swagger UI**, **Postman**, or other API tools for visualization and testing.
88+
89+
## Example Usage
90+
7691
**Example (cURL):**
7792

7893
```bash

packages/cli/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ objectql serve
3232
objectql serve --dir ./src/schema --port 8080
3333
```
3434

35+
The server exposes:
36+
* **JSON API Endpoint**: `http://localhost:<port>/` (POST)
37+
* **OpenAPI Spec**: `http://localhost:<port>/openapi.json` (GET) - Import this into Postman or Swagger UI.
38+
3539
### `repl` (alias: `r`)
3640

3741
Start an interactive shell to query your data.

0 commit comments

Comments
 (0)