Skip to content

Commit

Permalink
feat(uit): backstage links und swagger ui fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurzydym committed Apr 24, 2024
1 parent 907f0fb commit b6cba51
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backstage/examples/address-validation-service/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "address-validation-service",
"links": [{
"url": "http://address-validation.ok-cluster.azure.cloud.openknowledge.services/webjars/swagger-ui/index.html",
"title": "Customer Service"
"title": "Address Validation Service"
}],
"annotations": {
"backstage.io/managed-by-origin-location": "url:http://localhost:9080/service-repository/api/backstage/catalog-info.yaml",
Expand Down
2 changes: 1 addition & 1 deletion backstage/examples/billing-service/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "billing-service",
"links": [{
"url": "http://billing.ok-cluster.azure.cloud.openknowledge.services/webjars/swagger-ui/index.html",
"title": "Customer Service"
"title": "Billing Service"
}],
"annotations": {
"backstage.io/managed-by-origin-location": "url:http://localhost:9080/service-repository/api/backstage/catalog-info.yaml",
Expand Down
2 changes: 1 addition & 1 deletion backstage/examples/delivery-service/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "delivery-service",
"links": [{
"url": "http://delivery.ok-cluster.azure.cloud.openknowledge.services/webjars/swagger-ui/index.html",
"title": "Customer Service"
"title": "Delivery Service"
}],
"annotations": {
"backstage.io/managed-by-origin-location": "url:http://localhost:9080/service-repository/api/backstage/catalog-info.yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.*;
import java.util.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -45,11 +41,12 @@ public class SwaggerUiResource {
public Response getWebJarsResource(@PathParam("path") String path) {
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(String.format("META-INF/resources/%s", path));
BufferedReader buffer = new BufferedReader(new InputStreamReader(inputStream));
StringWriter content = new StringWriter()) {
buffer.lines().forEach(content::write);
StringWriter writer = new StringWriter();
PrintWriter content = new PrintWriter(writer)) {
buffer.lines().forEach(content::println);

String mediaType = path.endsWith(".js") ? "application/javascript" : "text/" + path.substring(path.lastIndexOf('.') + 1);
return Response.ok(content.toString()).type(mediaType).build();
return Response.ok(writer.toString()).type(mediaType).build();
} catch (NullPointerException e) {
LOG.log(WARNING, "Could not find resource [{0}]", path);
return Response.status(NOT_FOUND).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: "3.0.1"
info:
title: Billing Service V1
version: 1.1.0
version: "1.1.1"
components:
schemas:
Address:
Expand Down Expand Up @@ -64,13 +64,21 @@ paths:
schema:
type: "object"
$ref: "#/components/schemas/Address"
application/vnd.de.openknowledge.sample.address.v1+json:
schema:
type: "object"
$ref: "#/components/schemas/Address"
description: "default response"
default:
content:
application/json:
schema:
type: "object"
$ref: "#/components/schemas/Address"
application/vnd.de.openknowledge.sample.address.v1+json:
schema:
type: "object"
$ref: "#/components/schemas/Address"
description: "default response"
post:
parameters:
Expand All @@ -92,6 +100,11 @@ paths:
properties: {}
type: "object"
nullable: true
application/vnd.de.openknowledge.sample.address.v1+json:
schema:
properties: {}
type: "object"
nullable: true
description: "default response"
default:
content:
Expand All @@ -100,6 +113,11 @@ paths:
properties: {}
type: "object"
nullable: true
application/vnd.de.openknowledge.sample.address.v1+json:
schema:
properties: { }
type: "object"
nullable: true
description: "default response"
requestBody:
content:
Expand All @@ -108,3 +126,7 @@ paths:
type: "object"
$ref: "#/components/schemas/Address"
required: true
application/vnd.de.openknowledge.sample.address.v1+json:
schema:
type: "object"
$ref: "#/components/schemas/Address"

0 comments on commit b6cba51

Please sign in to comment.