0.1.0 • Published 4 months ago

@tsdiapi/meta v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

TSDIAPI Meta Plugin

A TSDIAPI plugin for automatic OpenAPI metadata generation, schema validation, and extended route information extraction.


šŸ“Œ About

The TSDIAPI Meta Plugin extends the TSDIAPI framework by providing powerful tools to dynamically generate OpenAPI metadata, validate schemas, and extract route information. This plugin is designed for developers who need structured API metadata, automated validation, and enhanced introspection of API routes.

šŸ”— TSDIAPI CLI: @tsdiapi/cli


šŸ“¦ Installation

Install the plugin using the TSDIAPI CLI:

tsdiapi plugins add meta

Then, register the plugin in your TSDIAPI project:

import { createApp } from "@tsdiapi/server";
import createPlugin from "@tsdiapi/meta";

createApp({
  plugins: [createPlugin()],
});

šŸš€ Features

  • šŸ“„ Automatic OpenAPI Spec Generation – Generates OpenAPI documentation based on your defined routes and controllers.
  • āœ… Schema Validation – Provides runtime validation of request/response data based on class-validator decorators.
  • šŸ” Route Metadata Extraction – Fetch details about available routes, input/output schemas, and API controllers.
  • šŸ“‹ Form Field Processing – Converts JSON Schema into structured form field representations.
  • šŸ— Seamless Integration – Works with existing TSDIAPI projects without additional configuration.

šŸ”§ Configuration

The plugin does not require additional configuration. Simply install and use it!

createPlugin();

šŸ“Œ How to Use

Once installed, the plugin automatically provides API metadata functionality. The main entry points are the MetaProvider and the MetaController, which expose useful methods.

Using the MetaProvider

import { getMetaProvider } from "@tsdiapi/meta";

const meta = getMetaProvider();

// Retrieve OpenAPI specification
const apiSpec = meta.getApiSpec();

// Get all available routes
const routes = meta.getAllRoutes();

MetaController (Automatic API Endpoints)

The plugin also provides a built-in MetaController that exposes various endpoints for retrieving metadata:

Here is the table in Markdown format:

API Endpoints for MetaController

HTTP MethodEndpointDescription
GET/api-specRetrieves the full OpenAPI specification of the API.
GET/api-source-specRetrieves the raw OpenAPI specification before processing.
GET/route-typesGets all input and output types for a specified route.
GET/route-types/inputGets the input type schema for a specified route.
GET/route-types/outputGets the output type schema for a specified route.
GET/routesRetrieves all registered API routes.
GET/controllersRetrieves all registered controllers and their routes.
GET/routeRetrieves metadata for a specified route.
GET/route-sourceRetrieves raw metadata for a specified route.
GET/schema/:nameRetrieves the schema definition for a specified DTO.
GET/dtosLists all available DTOs.
GET/schemasRetrieves all registered schemas.
GET/source-schemaRetrieves the raw JSON schema definitions.
GET/fields/:nameRetrieves form fields extracted from a specified schema.
GET/response-fieldsRetrieves response field definitions for a specified route.
GET/request-fieldsRetrieves request field definitions for a specified route.

šŸ“‘ Example: Generate a Controller

This plugin provides a generator to create a new controller in your API. To generate a controller:

tsdiapi generate meta

This command will create a new controller in your project.

āœ… After generating the controller, you can immediately use it in your API!


šŸ‘Øā€šŸ’» Contributing

Contributions are welcome! If you have ideas for improvements, feel free to open a pull request.

Author: unbywyd
šŸ“§ Contact: unbywyd@gmail.com

šŸš€ Happy coding with TSDIAPI! šŸŽ‰

0.1.0

4 months ago

0.0.2-alpha.1

4 months ago

0.0.1-alpha.8

5 months ago

0.0.1-alpha.7

5 months ago

0.0.1-alpha.6

5 months ago

0.0.1-alpha.5

5 months ago

0.0.1-alpha.4

5 months ago

0.0.1-alpha.3

5 months ago

0.0.1-alpha.2

5 months ago

0.0.1-alpha.1

5 months ago