@flink-app/api-docs-plugin v0.12.1-alpha.19
Flink API Docs Plugin
A FLINK plugin that automatically generates beautiful API documentation based on your app's registered routes and schemas. This plugin provides a modern, Swagger-like interface for exploring and understanding your API endpoints.
Features
- 🚀 Automatic API documentation generation
- 🔍 Detailed request/response schema documentation
Installation
Install the plugin to your Flink app project:
npm i -S @flink-app/api-docs-pluginUsage
Add and configure the plugin in your app startup (typically in your root index.ts):
import { apiDocPlugin } from "@flink-app/api-docs-plugin";
function start() {
new FlinkApp<AppContext>({
name: "My app",
plugins: [
// Register plugin with custom options
apiDocPlugin({
title: "API Docs: My app",
path: "/docs", // Optional: defaults to "/docs"
apiPath: "/docs/api", // Optional: defaults to "/docs/api"
}),
],
}).start();
}Configuration Options
The plugin accepts the following configuration options:
| Option | Type | Default | Description |
|---|---|---|---|
path | string | /docs | The URL path where the documentation is served |
apiPath | string | /docs/api | The URL path where the API data is served |
name | string | - | Custom name for the plugin instance |
title | string | API Docs | The title displayed in the documentation UI |
How It Works
The plugin automatically:
- Sets up a static file server at the specified path (defaults to
/docs) - Creates an API endpoint at
/docs/apithat exposes route information - Serves a React application that fetches and displays your API documentation
- Groups endpoints by resource for better organization
- Displays detailed request/response schemas with proper TypeScript types
Development
For local development of the API documentation UI:
Start the mock API server:
npm run dev:mock-apiIn another terminal, start the React development server:
npm run dev:reactOpen http://localhost:5173 in your browser
The development setup includes hot-reloading for the React application, allowing you to see changes instantly as you modify the UI components.
Architecture
The plugin consists of two main parts:
- Express Plugin: Integrates with your Flink application to serve the documentation
- React Application: Modern UI that displays the API documentation
The React app uses:
- Tailwind CSS for styling
- TypeScript for type safety
- Vite for fast development and building
Requirements
- Node.js v20.17.0 or higher (as specified in root .nvmrc)
- A Flink application with Express initialized
UI Features
- Method Badges: Color-coded HTTP method indicators (GET, POST, PUT, DELETE, etc.)
- Expandable Sections: Click on endpoints to view detailed information
- Schema Tables: Well-formatted tables showing request/response properties
- Type Information: Clear display of property types and requirements
- Description Support: Built-in support for endpoint and property descriptions
- Mock Endpoint Indicators: Visual indicators for mocked endpoints
- Responsive Design: Works seamlessly on desktop and mobile devices
- TypeScript Interface Generation: Copy TypeScript interfaces for request/response bodies
Building
To build the complete plugin:
npm run prepareThis will:
- Build the React application
- Compile TypeScript files
- Copy all necessary assets to the dist directory
The built plugin can then be published to npm and used in any Flink application.
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
12 months ago
8 months ago
8 months ago
8 months ago
1 year ago
1 year ago
1 year ago
10 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago