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.
- 🚀 Automatic API documentation generation
- 🔍 Detailed request/response schema documentation
Install the plugin to your Flink app project:
npm i -S @flink-app/api-docs-plugin
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();
}
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 |
The plugin automatically:
- Sets up a static file server at the specified path (defaults to
/docs
) - Creates an API endpoint at
/docs/api
that 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
For local development of the API documentation UI:
-
Start the mock API server:
npm run dev:mock-api
-
In another terminal, start the React development server:
npm run dev:react
-
Open 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.
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
- Node.js v20.17.0 or higher (as specified in root .nvmrc)
- A Flink application with Express initialized
- 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
To build the complete plugin:
npm run prepare
This 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.