Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped support for OpenAPI v2 Swagger specification. #959

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cf88d8909114896517ba4027596382126bca594d55dd9a924330232407e603b2
638e4ea2961241ead6552ccef364f2617c3b602e4bf9dff7786f5c463b07d063
16 changes: 8 additions & 8 deletions documentation/book/api/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ endif::internal-generation[]

===== Description

Retrieves the OpenAPI v2 specification in JSON format.
Retrieves the OpenAPI v3 specification in JSON format.


// markup not found, no include::{specDir}openapi/GET/spec.adoc[opts=optional]
Expand Down Expand Up @@ -1467,7 +1467,7 @@ Retrieves the OpenAPI v2 specification in JSON format.


| 200
| OpenAPI v2 specification in JSON format retrieved successfully.
| OpenAPI v3 specification in JSON format retrieved successfully.
| <<String>>

|===
Expand Down Expand Up @@ -1503,7 +1503,7 @@ endif::internal-generation[]

===== Description

Retrieves the OpenAPI v2 specification in JSON format.
OpenAPI v2 Swagger not supported.


// markup not found, no include::{specDir}openapi/v2/GET/spec.adoc[opts=optional]
Expand All @@ -1522,12 +1522,12 @@ Retrieves the OpenAPI v2 specification in JSON format.



<<String>>

-

===== Content Type

* application/json
* application/vnd.kafka.v2+json

===== Responses

Expand All @@ -1537,9 +1537,9 @@ Retrieves the OpenAPI v2 specification in JSON format.
| Code | Message | Datatype


| 200
| OpenAPI v2 specification in JSON format retrieved successfully.
| <<String>>
| 410
| OpenAPI v2 Swagger not supported.
| <<Error>>

|===

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Kafka Bridge OpenAPI specification is in JSON format.
You can find the OpenAPI JSON files in the `src/main/resources/` folder of the Kafka Bridge source download files.
The download files are available from the {ReleaseDownload}.

You can also use the xref:openapi[`GET /openapi` method] to retrieve the OpenAPI v2 specification in JSON format.
You can also use the xref:openapi[`GET /openapi` method] to retrieve the OpenAPI v3 specification in JSON format.

[role="_additional-resources"]
.Additional resources
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
22 changes: 15 additions & 7 deletions src/main/resources/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1415,29 +1415,37 @@
}
}
},
"description": "OpenAPI v2 specification in JSON format retrieved successfully."
"description": "OpenAPI v3 specification in JSON format retrieved successfully."
}
},
"operationId": "openapi",
"description": "Retrieves the OpenAPI v2 specification in JSON format."
"description": "Retrieves the OpenAPI v3 specification in JSON format."
}
},
"/openapi/v2": {
"get": {
"responses": {
"200": {
"410": {
"content": {
"application/json": {
"application/vnd.kafka.v2+json": {
"schema": {
"type": "string"
"$ref": "#/components/schemas/Error"
},
"examples": {
"response": {
"value": {
"error_code": 410,
"message": "OpenAPI v2 Swagger not supported."
}
}
}
}
},
"description": "OpenAPI v2 specification in JSON format retrieved successfully."
"description": "OpenAPI v2 Swagger not supported."
}
},
"operationId": "openapiv2",
"description": "Retrieves the OpenAPI v2 specification in JSON format."
"description": "OpenAPI v2 Swagger not supported."
}
},
"/openapi/v3": {
Expand Down
Loading
Loading