Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc829f3a

Browse files
author
FalkWolsky
committed
Updating API Auto-Docs
1 parent849452d commitc829f3a

File tree

6 files changed

+108
-87
lines changed

6 files changed

+108
-87
lines changed

‎server/api-service/lowcoder-server/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
<artifactId>lowcoder-plugin-api</artifactId>
5757
</dependency>
5858

59-
<dependency>
60-
<groupId>ch.qos.logback</groupId>
61-
<artifactId>logback-classic</artifactId>
62-
</dependency>
59+
<dependency>
60+
<groupId>ch.qos.logback</groupId>
61+
<artifactId>logback-classic</artifactId>
62+
</dependency>
6363
<dependency>
6464
<groupId>org.springframework.boot</groupId>
6565
<artifactId>spring-boot-starter-security</artifactId>
@@ -77,6 +77,11 @@
7777
<groupId>org.springdoc</groupId>
7878
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
7979
</dependency>
80+
<dependency>
81+
<groupId>org.springdoc</groupId>
82+
<artifactId>springdoc-openapi-core</artifactId>
83+
<version>1.1.49</version>
84+
</dependency>
8085
<dependency>
8186
<groupId>io.projectreactor.tools</groupId>
8287
<artifactId>blockhound</artifactId>

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/OpenAPIDocsConfiguration.java

Lines changed: 75 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,114 +2,108 @@
22

33
importio.swagger.v3.oas.models.Components;
44
importio.swagger.v3.oas.models.OpenAPI;
5+
importio.swagger.v3.oas.models.PathItem;
6+
importio.swagger.v3.oas.models.Paths;
57
importio.swagger.v3.oas.models.info.Info;
68
importio.swagger.v3.oas.models.security.SecurityRequirement;
79
importio.swagger.v3.oas.models.security.SecurityScheme;
810
importio.swagger.v3.oas.models.servers.Server;
911
importio.swagger.v3.oas.models.servers.ServerVariable;
1012
importio.swagger.v3.oas.models.servers.ServerVariables;
13+
importio.swagger.v3.oas.models.tags.Tag;
1114
importorg.lowcoder.sdk.config.CommonConfig;
15+
importorg.springdoc.api.OpenApiCustomiser;
1216
importorg.springframework.beans.factory.annotation.Autowired;
1317
importorg.springframework.beans.factory.annotation.Value;
1418
importorg.springframework.context.annotation.Bean;
1519
importorg.springframework.context.annotation.Configuration;
1620

1721
importjava.util.Arrays;
22+
importjava.util.Comparator;
23+
importjava.util.Map;
24+
importjava.util.TreeMap;
1825

1926
@Configuration
2027
publicclassOpenAPIDocsConfiguration {
28+
2129
@Autowired
2230
privateCommonConfigcommonConfig;
2331

2432
@Value("${server.port:8080}")
2533
privateintserverPort;
26-
34+
2735
@Value("${spring.webflux.base-path:/}")
2836
privateStringcontextPath;
29-
30-
@Bean
31-
OpenAPIcustomizeOpenAPI() {
3237

38+
/**
39+
* Configures the core OpenAPI spec including servers, security and info.
40+
*/
41+
@Bean
42+
publicOpenAPIcustomizeOpenAPI() {
3343
finalStringsecuritySchemeName =commonConfig.getCookieName();
3444

3545
returnnewOpenAPI()
36-
.info(newInfo()
37-
.title("Lowcoder Open Rest API")
38-
.version(commonConfig.getApiVersion()))
39-
/*.addServersItem(new Server()
40-
.url(createLocalServerUrl("localhost", serverPort, contextPath))
41-
.description("Local development API service")
42-
) */
43-
.addServersItem(createCustomServer())
44-
.addServersItem(newServer()
45-
.url("https://api-service.lowcoder.cloud/")
46-
.description("Lowcoder Community Edition: Public Cloud API Access")
47-
)
48-
.addSecurityItem(newSecurityRequirement()
49-
.addList(securitySchemeName)).components(newComponents()
50-
/* .addSecuritySchemes(
51-
securitySchemeName,
52-
new SecurityScheme()
53-
.name(securitySchemeName)
54-
.type(SecurityScheme.Type.HTTP) // HTTP-based authentication
55-
.scheme("cookie") // Specify the authentication scheme as "cookie"
56-
.description("Cookie-based authentication. Please ensure the client sends cookies with each request after authentication.")
57-
) */
58-
.addSecuritySchemes(
59-
"API Key",
60-
newSecurityScheme()
61-
.name("Authorization")
62-
.type(SecurityScheme.Type.APIKEY)
63-
.in(SecurityScheme.In.HEADER)
64-
.scheme("bearer")
65-
.bearerFormat("JWT")
66-
.description("API Key Authentication with a Bearer token. Copy your API Key and prefix it here with 'Bearer ' (e.g. 'Bearer eyJhbGciO...'")
67-
)
68-
);
46+
.info(newInfo()
47+
.title("Lowcoder Open Rest API")
48+
.version(commonConfig.getApiVersion()))
49+
.addServersItem(createCustomServer())
50+
.addServersItem(newServer()
51+
.url("https://api-service.lowcoder.cloud/")
52+
.description("Lowcoder Community Edition: Public Cloud API Access"))
53+
.addSecurityItem(newSecurityRequirement().addList(securitySchemeName))
54+
.components(newComponents()
55+
.addSecuritySchemes("API Key",newSecurityScheme()
56+
.name("Authorization")
57+
.type(SecurityScheme.Type.APIKEY)
58+
.in(SecurityScheme.In.HEADER)
59+
.scheme("bearer")
60+
.bearerFormat("JWT")
61+
.description("API Key Authentication with a Bearer token. Copy your API Key and prefix it here with 'Bearer ' (e.g. 'Bearer eyJhbGciO...')")));
6962
}
70-
71-
72-
/* private static String createLocalServerUrl(String domain, int port, String contextPath)
73-
{
74-
StringBuilder sb = new StringBuilder("http");
75-
76-
if (port == 443)
77-
{
78-
sb.append("s");
79-
}
80-
sb.append("://").append(domain);
8163

82-
if (port != 80 && port != 443)
83-
{
84-
sb.append(":").append(port);
85-
}
86-
sb.append(contextPath);
87-
88-
return sb.toString();
89-
} */
90-
91-
privateServercreateCustomServer()
92-
{
93-
Stringurl ="{scheme}://{domain}:{port}{basePath}";
94-
95-
Serverserver =newServer()
96-
.description("Lowcoder Self-hosted Installation API Access")
97-
.url(url)
98-
.variables(newServerVariables()
99-
.addServerVariable("scheme",newServerVariable()
100-
._default("http")
101-
.description("HTTP scheme")
102-
._enum(Arrays.asList("http","https")))
103-
.addServerVariable("domain",newServerVariable()
104-
.description("Lowcoder IP address or domain")
105-
._default("localhost"))
106-
.addServerVariable("port",newServerVariable()
107-
.description("Port")
108-
._default("3000"))
109-
.addServerVariable("basePath",newServerVariable()
110-
.description("Base path")
111-
._default(contextPath))
112-
);
113-
returnserver;
64+
/**
65+
* Creates a dynamic server entry using server variables.
66+
*/
67+
privateServercreateCustomServer() {
68+
Stringurl ="{scheme}://{domain}:{port}{basePath}";
69+
70+
returnnewServer()
71+
.description("Lowcoder Self-hosted Installation API Access")
72+
.url(url)
73+
.variables(newServerVariables()
74+
.addServerVariable("scheme",newServerVariable()
75+
._default("http")
76+
.description("HTTP scheme")
77+
._enum(Arrays.asList("http","https")))
78+
.addServerVariable("domain",newServerVariable()
79+
.description("Lowcoder IP address or domain")
80+
._default("localhost"))
81+
.addServerVariable("port",newServerVariable()
82+
.description("Port")
83+
._default("3000"))
84+
.addServerVariable("basePath",newServerVariable()
85+
.description("Base path")
86+
._default(contextPath)));
87+
}
88+
89+
/**
90+
* Customizes the OpenAPI spec at runtime to sort tags and paths.
91+
*/
92+
@Bean
93+
publicOpenApiCustomisersortOpenApiSpec() {
94+
returnopenApi -> {
95+
// Sort tags alphabetically
96+
if (openApi.getTags() !=null) {
97+
openApi.getTags().sort(Comparator.comparing(Tag::getName));
98+
}
99+
100+
// Sort paths alphabetically by their URL
101+
if (openApi.getPaths() !=null) {
102+
Map<String,PathItem>sorted =newTreeMap<>(openApi.getPaths());
103+
PathssortedPaths =newPaths();
104+
sorted.forEach(sortedPaths::addPathItem);
105+
openApi.setPaths(sortedPaths);
106+
}
107+
};
114108
}
115-
}
109+
}

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/application/ApplicationEndpoints.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ public Mono<ResponseView<ApplicationView>> publish(@PathVariable String applicat
149149
publicMono<ResponseView<Boolean>>updateEditState(@PathVariableStringapplicationId,
150150
@RequestBodyUpdateEditStateRequestupdateEditStateRequest);
151151

152+
@Operation(
153+
tags =TAG_APPLICATION_MANAGEMENT,
154+
operationId ="updateApplicationSlug",
155+
summary ="Update Application URL Path Slug",
156+
description ="The slug is used to build a friendly reader URL for Apps instead of the ID"
157+
)
152158
@PutMapping("/{applicationId}/slug")
153159
publicMono<ResponseView<Application>>updateSlug(@PathVariableStringapplicationId,@RequestBodyStringslug);
154160

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/IndexController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55
importorg.springframework.http.MediaType;
66
importorg.springframework.web.bind.annotation.GetMapping;
77
importorg.springframework.web.bind.annotation.RestController;
8+
9+
importio.swagger.v3.oas.annotations.Operation;
810
importreactor.core.publisher.Mono;
911

1012
@RequiredArgsConstructor
1113
@RestController
1214
publicclassIndexController {
1315

16+
publicstaticfinalStringTAG_ROOT ="API Root Endpoint";
17+
18+
@Operation(
19+
tags =TAG_ROOT,
20+
operationId ="getHelloWorld",
21+
summary ="Get the hello world Message from Lowcoder API",
22+
description ="Retrieve the Hello World Message. If the API Service operates normal, the response is: {\"code\":1,\"message\":\"Lowcoder API is up and runnig\",\"success\":true}"
23+
)
1424
@GetMapping(value ="/",consumes = {MediaType.ALL_VALUE})
1525
publicMono<ResponseView<Void>>index() {
1626
returnMono.just(ResponseView.error(ResponseView.SUCCESS,"Lowcoder API is up and runnig"));

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/OrganizationEndpoints.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ public Mono<ResponseView<Boolean>> removeUserFromOrg(@PathVariable String orgId,
181181
@GetMapping("/{orgId}/api-usage")
182182
publicMono<ResponseView<Long>>getOrgApiUsageCount(@PathVariableStringorgId,@RequestParam(required =false)BooleanlastMonthOnly);
183183

184+
@Operation(
185+
tags =TAG_ORGANIZATION_MANAGEMENT,
186+
operationId ="updateOrganizationSlug",
187+
summary ="Update Organization URL Path Slug",
188+
description ="The slug is used to build a friendly reader URL for Apps. The Organization (workspace) get a part of this URL with an own slug."
189+
)
184190
@PutMapping("/{orgId}/slug")
185191
Mono<ResponseView<Organization>>updateSlug(@PathVariableStringorgId,@RequestBodyStringslug);
186192

‎server/api-service/lowcoder-server/src/main/resources/application.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ common:
6464
domain:
6565
default-value:lowcoder.org
6666
cloud:false
67-
version:2.1.4
68-
apiVersion:1.1
67+
version:2.7.0
68+
apiVersion:1.2
6969
block-hound-enable:false
7070
encrypt:
7171
password:${LOWCODER_DB_ENCRYPTION_PASSWORD:lowcoder.org}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp