# seaboot-openapi **Repository Path**: seaboot/seaboot-openapi ## Basic Information - **Project Name**: seaboot-openapi - **Description**: 基于springdoc,提供更好的openapi,支持将系统接口直接导入到postman中。 - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 1 - **Created**: 2020-11-03 - **Last Updated**: 2026-03-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: Swagger ## README ## seaboot-openapi 如果项目中存在大量的自定义接口、注解,会导致 swagger 的扫描不彻底,效果不尽如人意。 #### 关于 OpenAPI 3.0 OpenAPI 3.0(原 Swagger 规范)是当前最流行的 API 描述规范,用于定义 rest-ful API 的接口文档、数据模型、安全机制等,支持自动化生成客户端/服务端代码、测试工具和交互式文档。 #### 开发目的 不希望 OpenAPI 3.0 过多得影响到代码的写法,对于项目中已有的配置,不重复使用注解,从相关配置中,直接获取 OpenAPI 3.0 规定的信息。 * 减少重复的配置,兼容各种缺省值; * 如果采用了 javax.validation/hibernate-validation 注解,则优先使用相关注解的信息; #### 使用场景 导出 json 或者 yaml 格式的接口文件,导入到 postman 或者其他 UI 插件中使用。 ```java public class Test { public static void main(String[] args) { Info info = new Info() .version("1.0") .title("用户管理API") .description("用户管理系统的RESTFul API文档") .contact(new Contact().name("API支持团队").email("apisupport@example.com")) .license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")); Configuration configuration = new Configuration(); configuration.withResponseParser(); String api = OpenAPIBuilder.create(configuration) .search(AppInfoCtrl.class) .setInfo(info) .addService(new Server().description("生产环境").url("https://api.example.com/v1")) .addService(new Server().description("测试环境").url("https://staging-api.example.com/v1")) .toJson(); System.out.println(api); } } ``` #### 兼容 标准:OpenAPI 3.0 仅用到 spring-doc 包下的 swagger-annotations 和 swagger-models。 #### 参与贡献 1. Mr.css