Skip to content

Commit 2a1f73f

Browse files
authored
feat: add swagger (#438)
* fix: add swagger * fix: ci
1 parent e14a925 commit 2a1f73f

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

data-agent-management/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106
<artifactId>h2</artifactId>
107107
<scope>runtime</scope>
108108
</dependency>
109+
<dependency>
110+
<groupId>org.springframework.boot</groupId>
111+
<artifactId>spring-boot-starter-web</artifactId>
112+
</dependency>
113+
<dependency>
114+
<groupId>org.springdoc</groupId>
115+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
116+
<version>${springdoc-openapi.version}</version>
117+
</dependency>
118+
109119
<dependency>
110120
<groupId>org.springframework.boot</groupId>
111121
<artifactId>spring-boot-testcontainers</artifactId>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2024-2026 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.alibaba.cloud.ai.dataagent.config;
17+
18+
import io.swagger.v3.oas.models.OpenAPI;
19+
import io.swagger.v3.oas.models.info.Info;
20+
import org.springdoc.core.models.GroupedOpenApi;
21+
import org.springframework.context.annotation.Bean;
22+
import org.springframework.context.annotation.Configuration;
23+
24+
/**
25+
* OpenAPI/Swagger 配置。
26+
*/
27+
@Configuration
28+
public class OpenApiConfig {
29+
30+
@Bean
31+
public OpenAPI dataAgentOpenApi() {
32+
return new OpenAPI()
33+
.info(new Info().title("DataAgent Backend API").description("DataAgent 后端接口文档").version("v1"));
34+
}
35+
36+
@Bean
37+
public GroupedOpenApi dataAgentApiGroup() {
38+
return GroupedOpenApi.builder()
39+
.group("data-agent")
40+
.packagesToScan("com.alibaba.cloud.ai.dataagent.controller")
41+
.pathsToMatch("/api/**")
42+
.build();
43+
}
44+
45+
}

data-agent-management/src/main/resources/application.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
server:
22
port: 8065
33

4+
springdoc:
5+
api-docs:
6+
path: /v3/api-docs
7+
swagger-ui:
8+
path: /swagger-ui.html
9+
410
# 存储 DataAgent 业务数据的数据库,并非Agent分析数据的来源
511
spring:
612
datasource:

0 commit comments

Comments
 (0)