Skip to content

Commit

Permalink
Update to JDK 17, SpringBoot 3 + OpenAPI (#482)
Browse files Browse the repository at this point in the history
* Update for SpringBoot 3.0.4
* Use of JDK 17
* Migration from SpringFox to SpringDoc OpenAPI
  • Loading branch information
mehdihasan authored Apr 1, 2023
1 parent 4fe1e64 commit d64253d
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 241 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v3
-
name: Set up JDK 11
name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
-
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Build with Maven
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This project is a reboot of Kafdrop 2.x, dragged kicking and screaming into the

# Requirements

* Java 11 or newer
* Java 17 or newer
* Kafka (version 0.11.0 or newer) or Azure Event Hubs

Optional, additional integration:
Expand Down Expand Up @@ -180,22 +180,25 @@ Starting with version 2.0.0, Kafdrop offers a set of Kafka APIs that mirror the

* `/topic`: Returns a list of all topics.

## Swagger
To help document the Kafka APIs, Swagger has been included. The Swagger output is available by default at the following Kafdrop URL:
## OpenAPI Specification (OAS)
To help document the Kafka APIs, OpenAPI Specification (OAS) has been included. The OpenAPI Specification output is available by default at the following Kafdrop URL:
```
/v2/api-docs
/v3/api-docs
```

This can be overridden with the following configuration:
It is also possible to access the Swagger UI (the HTML views) from the following URL:
```
springfox.documentation.swagger.v2.path=/new/swagger/path
/swagger-ui.html
```

Currently only the JSON endpoints are included in the Swagger output; the HTML views and Spring Boot debug endpoints are excluded.
This can be overridden with the following configuration:
```
springdoc.api-docs.path=/new/oas/path
```

You can disable Swagger output with the following configuration:
You can disable OpenAPI Specification output with the following configuration:
```
swagger.enabled=false
springdoc.api-docs.enabled=false
```

## CORS Headers
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<version>3.0.4</version>
</parent>
<groupId>com.obsidiandynamics.kafdrop</groupId>
<artifactId>kafdrop</artifactId>
<version>3.32.0-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>

<description>For when you have a Kafka cluster to monitor</description>

Expand Down Expand Up @@ -176,9 +176,9 @@

<!-- Swagger API docs -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.4</version>
</dependency>

<!-- Spring test -->
Expand Down Expand Up @@ -211,10 +211,10 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
<source>17</source>
<target>17</target>
<fork>true</fork>
<compilerVersion>11</compilerVersion>
<compilerVersion>17</compilerVersion>
<compilerArgs>
<arg>--add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED</arg>
</compilerArgs>
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11.0.18_10-jdk
FROM eclipse-temurin:17.0.6_10-jdk

ADD kafdrop.sh /
ADD kafdrop*tar.gz /
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/kafdrop/config/CorsConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.springframework.core.annotation.*;
import org.springframework.http.*;

import javax.servlet.*;
import javax.servlet.http.*;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.*;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kafdrop/config/InterceptorConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.springframework.web.servlet.*;
import org.springframework.web.servlet.config.annotation.*;

import javax.servlet.http.*;
import jakarta.servlet.http.*;

@Component
public class InterceptorConfiguration implements WebMvcConfigurer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.context.annotation.*;
import org.springframework.stereotype.*;

import javax.annotation.*;
import jakarta.annotation.*;


@Configuration
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/kafdrop/config/OASConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2017 Kafdrop contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package kafdrop.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Autoconfiguration for OpenAPI Specification (OAS).
* Can be disabled by setting {@code springdoc.api-docs.enabled=false}.
*/
@Configuration
public class OASConfiguration {

@Bean
public OpenAPI httpApi() {
return new OpenAPI().info(new Info()
.title("Kafdrop API")
.description("JSON APIs for Kafdrop"));
}
}
117 changes: 0 additions & 117 deletions src/main/java/kafdrop/config/SwaggerConfiguration.java

This file was deleted.

15 changes: 7 additions & 8 deletions src/main/java/kafdrop/controller/AclController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

package kafdrop.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import kafdrop.model.AclVO;
import kafdrop.service.KafkaMonitor;
import org.springframework.http.MediaType;
Expand All @@ -32,6 +33,7 @@

import java.util.List;

@Tag(name = "acl-controller", description = "ACL Controller")
@Controller
public final class AclController {
private final KafkaMonitor kafkaMonitor;
Expand All @@ -44,14 +46,11 @@ public AclController(KafkaMonitor kafkaMonitor) {
public String acls(Model model) {
final var acls = kafkaMonitor.getAcls();
model.addAttribute("acls", acls);

return "acl-overview";
}

@ApiOperation(value = "getAllAcls", notes = "Get list of all acls")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = String.class, responseContainer = "List")
})
@Operation(summary = "getAllAcls", description = "Get list of all acls", operationId = "getAllTopicsUsingGET")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Success")})
@GetMapping(path = "/acl", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<AclVO> getAllTopics() {
return kafkaMonitor.getAcls();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kafdrop/controller/BasicErrorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.*;

import javax.servlet.http.*;
import jakarta.servlet.http.*;
import java.util.*;

@Controller
Expand Down
Loading

0 comments on commit d64253d

Please sign in to comment.