https://github.com/patriciasegantine/open-api-swagger
A Fastify + TypeScript REST API exploring OpenAPI documentation with TypeBox schema validation and Scalar interactive docs.
https://github.com/patriciasegantine/open-api-swagger
api-docs fastify nodejs openai-api rest-api scalar swagger typebox typescript
Last synced: 27 days ago
JSON representation
A Fastify + TypeScript REST API exploring OpenAPI documentation with TypeBox schema validation and Scalar interactive docs.
- Host: GitHub
- URL: https://github.com/patriciasegantine/open-api-swagger
- Owner: patriciasegantine
- Created: 2026-03-26T23:01:06.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-03-29T10:54:55.000Z (about 1 month ago)
- Last Synced: 2026-04-04T01:49:10.443Z (27 days ago)
- Topics: api-docs, fastify, nodejs, openai-api, rest-api, scalar, swagger, typebox, typescript
- Language: TypeScript
- Homepage:
- Size: 106 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenAI API Exploration with Fastify
---
A simple project built to explore the OpenAI API using Fastify, TypeScript, and OpenAPI documentation.

> The idea was to keep the project intentionally small and use it as a practical way to experiment with the API, its responses, and the overall developer experience.
---
## Stack
- Node.js
- TypeScript
- Fastify
- @sinclair/typebox
- @fastify/type-provider-typebox
- @fastify/swagger
- @scalar/fastify-api-reference
- @fastify/cors
## Whatβs included
- Fastify server with TypeBox type provider
- Automatic OpenAPI schema generation from TypeBox schemas
- Full TypeScript type inference in route handlers
- Interactive API documentation with Scalar
- CORS support
- Sample `/users` endpoints (GET, POST, and GET by ID)
## Getting started
Install dependencies:
```bash
npm install
```
Run the development server:
```bash
npm run dev
```
The app runs at:
```plaintext
http://localhost:3333
```
## API documentation
OpenAPI JSON:
```plaintext
http://localhost:3333/openapi.json
```
Interactive docs (Scalar):
```plaintext
http://localhost:3333/docs
```
## Endpoints
### GET /users
Returns a paginated list of users.
**Query parameters**
| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | integer | `1` | Page number (min: 1) |
| `pageSize` | integer | `10` | Items per page (min: 1) |
**Example response**
```json
{
"total": 1,
"page": 1,
"pageSize": 10,
"data": [
{
"id": "a3bb189e-8bf9-3888-9912-ace4e6543002",
"name": "Alice",
"email": "alice@example.com"
}
]
}
```
### POST /users
Creates a new user. Requires Bearer token authentication.
**Request body**
```json
{
"name": "Alice",
"email": "alice@example.com"
}
```
**Responses**
| Status | Description |
|---|---|
| `201` | User created successfully |
| `400` | Validation error |
| `409` | Email already exists |
### GET /users/:id
Returns a single user by their UUID.
**Path parameters**
| Parameter | Type | Description |
|---|---|---|
| `id` | string (uuid) | The user's unique identifier |
**Responses**
| Status | Description |
|---|---|
| `200` | User found |
| `404` | User not found |
**Example response**
```json
{
"id": "a3bb189e-8bf9-3888-9912-ace4e6543002",
"name": "Alice",
"email": "alice@example.com"
}
```
---
> ## Notes
> Schemas are defined with TypeBox β a single source of truth for validation, TypeScript types, and OpenAPI documentation. No separate spec file needed.
---
### Licence
ISC
---
## π©βπ» Author
Created by **Patricia Segantine**
Senior Frontend Engineer | Exploring backend development
π GitHub: [@patriciasegantine](https://github.com/patriciasegantine)
π LinkedIn: [Patricia Segantine](https://www.linkedin.com/in/patriciasegantine/)