Skip to content

Commit

Permalink
Dropped support for OpenAPI v2 Swagger specification.
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Patierno <[email protected]>
  • Loading branch information
ppatierno committed Dec 23, 2024
1 parent 3c502ea commit 95a2c56
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2,120 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* Dependency updates (JMX exporter 1.1.0)
* Dropped support for Java 11 and replaced with Java 17.
* Dropped support for OpenAPI v2 Swagger specification.
* The `/openapi/v2` endpoint returns HTTP 410 Gone.
* Both the `/openapi` and `/openapi/v3` endpoints return the OpenAPI v3 definition of the bridge REST API.

## 0.31.1

Expand Down
12 changes: 5 additions & 7 deletions src/main/java/io/strimzi/kafka/bridge/http/HttpBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,12 @@ private void ready(RoutingContext routingContext) {

private void openapi(RoutingContext routingContext) {
FileSystem fileSystem = vertx.fileSystem();
fileSystem.readFile(openapiFileName(routingContext), readFile -> {
fileSystem.readFile("openapi.json", readFile -> {
if (readFile.succeeded()) {
String xForwardedPath = routingContext.request().getHeader("x-forwarded-path");
String xForwardedPrefix = routingContext.request().getHeader("x-forwarded-prefix");
if (xForwardedPath == null && xForwardedPrefix == null) {
HttpUtils.sendFile(routingContext, HttpResponseStatus.OK.code(), BridgeContentType.JSON, openapiFileName(routingContext));
HttpUtils.sendFile(routingContext, HttpResponseStatus.OK.code(), BridgeContentType.JSON, "openapi.json");
} else {
String path = "/";
if (xForwardedPrefix != null) {
Expand All @@ -553,10 +553,6 @@ private void openapi(RoutingContext routingContext) {
});
}

private String openapiFileName(RoutingContext routingContext) {
return "/openapi/v3".equals(routingContext.normalizedPath()) ? "openapi.json" : "openapiv2.json";
}

private void metrics(RoutingContext routingContext) {
routingContext.response()
.putHeader("Content-Type", "text/plain; version=0.0.4; charset=utf-8")
Expand Down Expand Up @@ -843,7 +839,9 @@ public void process(RoutingContext routingContext) {

@Override
public void process(RoutingContext routingContext) {
openapi(routingContext);
HttpBridgeError error = new HttpBridgeError(HttpResponseStatus.GONE.code(), "OpenAPI v2 Swagger not supported");
HttpUtils.sendResponse(routingContext, HttpResponseStatus.GONE.code(),
BridgeContentType.KAFKA_JSON, JsonUtils.jsonToBytes(error.toJson()));
}
};

Expand Down
Loading

0 comments on commit 95a2c56

Please sign in to comment.