@clean-js/api-gen
Version:
[docs](https://lulusir.github.io/clean-js/api-gen/usage) [中文文档](https://github.com/lulusir/clean-js-api-gen/blob/main/README-zh.md)
41 lines (40 loc) • 1.13 kB
TypeScript
import { OpenAPIV3, OpenAPIV2 } from "openapi-types";
export interface SchemaV3AST {
version: "OpenAPIV3";
schema: OpenAPIV3.SchemaObject;
}
export interface SchemaV2AST {
version: "OpenAPIV2";
schema: OpenAPIV2.SchemaObject;
}
export interface ComponentAST {
name: string;
$ref: string;
schema: SchemaV3AST;
}
type HttpMethods = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
export interface RequestAST {
id: string;
url: string;
method: HttpMethods;
description?: string;
pathParams?: Record<string, SchemaV3AST | SchemaV2AST>;
queryParams?: Record<string, SchemaV3AST | SchemaV2AST>;
bodyParams?: RequestBodyAST;
headers?: Record<string, SchemaV3AST | SchemaV2AST>;
responses?: ResponseAST[];
}
export interface RequestBodyAST {
type: "json" | "formData";
schema?: SchemaV3AST | SchemaV2AST;
}
export interface ResponseAST {
type: "json" | "javascript" | "html";
status: number;
schema?: SchemaV3AST | SchemaV2AST;
}
export interface RootAST {
components: ComponentAST[];
requests: RequestAST[];
}
export {};