gOAst (@goast/ core) (中文(简体) )
目标 代表着 页:1启动 欧笔 A 类个人信息 编号修饰 页:1ransformer,一个用于转换的工具 OpenAPI规格分为多种形式,其核心具有灵活性和可扩展性.
详情请访问 gOst GitHub 仓库。 。 。 .
目标
这个 @goast/core 软件包提供:
- 使用 目标 图书馆
- 创建自定义生成器的基础类
- openAPI 规格的解析和转换
用法示例 QQ
import { OpenApiGenerator } from '@goast/core';
class MyGenerator implements OpenApiGenerationProvider {
generate(
context: OpenApiGeneratorContext<OpenApiGeneratorInput>,
config?: Partial<Readonly<Record<string, unknown>>>,
): Record<string, unknown> {
// Do something
return {};
}
}
async function main() {
const generator = new OpenApiGenerator()
// Add a generator using a class
.useType(MyGenerator)
// Add a generator using a function
.useFn((ctx, cfg) => {
// Do the generation
return {}; // Return information about the generated files so it can be used by other generators
})
// Add a generator using an object implementing `OpenApiGenerationProvider`
.useValue({ generate: (ctx, cfg) => ({}) });
// Generate for one of more OpenAPI specification files
await generator.parseAndGenerate('path/to/openapi.json', 'path/to/another/openapi.yaml');
// Alternatively, you can generate output for all specifications in a directory.
// By default, it will only consider files within the directory (non-recursively) with the extensions: .json, .yaml, .yml.
await generator.parseAndGenerateFromDir('path/to/openapi/specs');
}
main();
可用的生成器软件包
API 文档 QQ
API 文档可见 这里。 。 。 .