From dee92f0e3ddf039723218b225ef10beb9677e3dc Mon Sep 17 00:00:00 2001 From: Artur Kolecki Date: Wed, 1 Mar 2023 11:44:21 +0100 Subject: [PATCH] Created swagger container and swagger documentation from ./Swagger/swagger.json (#87) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Artur KoĊ‚ecki Reviewed-on: https://gitea.release11.com/R11/release11-tools-web/pulls/87 --- Backend/mocked-services/pom.xml | 5 - .../com/r11/tools/config/SpringFoxConfig.java | 22 - Swagger/swagger.json | 915 ++++++++++++++++++ docker-compose.yml | 11 + readme.md | 3 + 5 files changed, 929 insertions(+), 27 deletions(-) delete mode 100644 Backend/mocked-services/src/main/java/com/r11/tools/config/SpringFoxConfig.java create mode 100644 Swagger/swagger.json diff --git a/Backend/mocked-services/pom.xml b/Backend/mocked-services/pom.xml index a3dd5ac..0a6ceb7 100644 --- a/Backend/mocked-services/pom.xml +++ b/Backend/mocked-services/pom.xml @@ -72,11 +72,6 @@ jettison 1.4.1 - - io.springfox - springfox-boot-starter - 3.0.0 - diff --git a/Backend/mocked-services/src/main/java/com/r11/tools/config/SpringFoxConfig.java b/Backend/mocked-services/src/main/java/com/r11/tools/config/SpringFoxConfig.java deleted file mode 100644 index 4d3da67..0000000 --- a/Backend/mocked-services/src/main/java/com/r11/tools/config/SpringFoxConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.r11.tools.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SpringFoxConfig { - @Bean - public Docket api(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.ant("/api/**")) - .build(); - } -} diff --git a/Swagger/swagger.json b/Swagger/swagger.json new file mode 100644 index 0000000..d180a3d --- /dev/null +++ b/Swagger/swagger.json @@ -0,0 +1,915 @@ +{ + "swagger": "2.0", + "info": { + "description": "Web tools api documentation.", + "version": "1.0", + "title": "Release11 Web Tools" + }, + "host": "tools.zipper.release11.com", + "schemes": [ + "http", + "https" + ], + "tags": [ + { + "name": "XPath", + "description": "XPath processing API" + }, + { + "name": "XSLT", + "description": "XSLT processing API" + }, + { + "name": "XSD", + "description": "XSD verification API" + }, + { + "name": "Mocked events", + "description": "Mocked events controller" + }, + { + "name": "Mocked services", + "description": "Mocked services controller" + } + ], + "paths": { + "/api/event": { + "post": { + "tags": [ + "Mocked events" + ], + "summary": "filterHistory", + "operationId": "filterHistoryUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "in": "body", + "name": "event", + "description": "event", + "required": true, + "schema": { + "$ref": "#/definitions/EventRequestDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/ResponseEntity" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/api/event/{uuid}/{messageId}": { + "get": { + "tags": [ + "Mocked events" + ], + "summary": "getLastDay", + "operationId": "getLastDayUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "messageId", + "in": "path", + "description": "messageId", + "required": true, + "type": "integer", + "format": "int32" + }, + { + "name": "uuid", + "in": "path", + "description": "uuid", + "required": true, + "type": "string", + "format": "uuid" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/ResponseEntity" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/api/mock": { + "put": { + "tags": [ + "Mocked services" + ], + "summary": "updateMessage", + "operationId": "updateMessageUsingPUT", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/api/mock/": { + "get": { + "tags": [ + "Mocked services" + ], + "summary": "getListOfMessages", + "operationId": "getListOfMessagesUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "uuidValue", + "in": "path", + "description": "uuidValue", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/MockedMessageDto" + } + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/api/mock/r/{clientUUID}/{mockedResponseId}": { + "get": { + "tags": [ + "Mocked services" + ], + "summary": "getMockedResponse", + "operationId": "getMockedResponseUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "body", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "clientUUID", + "in": "path", + "description": "clientUUID", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "name": "method", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "DELETE", + "GET", + "HEAD", + "OPTIONS", + "PATCH", + "POST", + "PUT", + "TRACE" + ] + }, + { + "name": "mockedResponseId", + "in": "path", + "description": "mockedResponseId", + "required": true, + "type": "integer", + "format": "int32" + }, + { + "name": "type", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "url", + "in": "query", + "required": false, + "type": "string", + "format": "uri" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/ResponseEntity" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/api/mock/{uuidValue}": { + "get": { + "tags": [ + "Mocked services" + ], + "summary": "getListOfMessages", + "operationId": "getListOfMessagesUsingGET_1", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "uuidValue", + "in": "path", + "description": "uuidValue", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/MockedMessageDto" + } + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Mocked services" + ], + "summary": "addNewMessage", + "operationId": "addNewMessageUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "uuidValue", + "in": "path", + "description": "uuidValue", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/api/mock/{uuidValue}/{idValue}": { + "delete": { + "tags": [ + "Mocked services" + ], + "summary": "removeMessage", + "operationId": "removeMessageUsingDELETE", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "idValue", + "in": "path", + "description": "idValue", + "required": true, + "type": "string" + }, + { + "name": "uuidValue", + "in": "path", + "description": "uuidValue", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "204": { + "description": "No Content" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + } + } + } + }, + "/xpathpost": { + "post": { + "tags": [ + "XPath" + ], + "summary": "Perform XPath transform on XML file", + "description": "", + "operationId": "xpath", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "request", + "description": "A transform that is to be performed", + "required": true, + "schema": { + "$ref": "#/definitions/RequestXPath" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Response" + } + } + }, + "400": { + "description": "Invalid status value", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ResponseError" + } + } + } + } + } + }, + "/xsltpost": { + "post": { + "tags": [ + "XSLT" + ], + "summary": "Perform XSLT transform on XML file", + "description": "", + "operationId": "xslt", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "request", + "description": "A transform that is to be performed", + "required": true, + "schema": { + "$ref": "#/definitions/RequestXSLT" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Response" + } + } + }, + "400": { + "description": "Invalid status value", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ResponseError" + } + } + } + } + } + }, + "/xsdpost": { + "post": { + "tags": [ + "XSD" + ], + "summary": "Verify XML file using XSD", + "description": "", + "operationId": "xsd", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "request", + "description": "A XML that is to be verified", + "required": true, + "schema": { + "$ref": "#/definitions/RequestXSD" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/XSDResponse" + } + } + }, + "400": { + "description": "Invalid status value", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/XSDError" + } + } + } + } + } + } + }, + "definitions": { + "EventRequestDto": { + "type": "object", + "properties": { + "clientUUID": { + "type": "string", + "format": "uuid" + }, + "localDateTimeFrom": { + "type": "string", + "format": "date-time" + }, + "localDateTimeTo": { + "type": "string", + "format": "date-time" + }, + "mockedResponseId": { + "type": "integer", + "format": "int32" + } + }, + "title": "EventRequestDto" + }, + "MockedMessageDto": { + "type": "object", + "required": [ + "mockedResponseId" + ], + "properties": { + "clientUUID": { + "type": "string", + "format": "uuid" + }, + "httpHeaders": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "httpStatus": { + "type": "integer", + "format": "int32" + }, + "mediaType": { + "type": "string" + }, + "messageBody": { + "type": "string" + }, + "mockedResponseId": { + "type": "integer", + "format": "int32" + } + }, + "title": "MockedMessageDto" + }, + "ResponseEntity": { + "type": "object", + "properties": { + "body": { + "type": "object" + }, + "statusCode": { + "type": "string", + "enum": [ + "ACCEPTED", + "ALREADY_REPORTED", + "BAD_GATEWAY", + "BAD_REQUEST", + "BANDWIDTH_LIMIT_EXCEEDED", + "CHECKPOINT", + "CONFLICT", + "CONTINUE", + "CREATED", + "DESTINATION_LOCKED", + "EXPECTATION_FAILED", + "FAILED_DEPENDENCY", + "FORBIDDEN", + "FOUND", + "GATEWAY_TIMEOUT", + "GONE", + "HTTP_VERSION_NOT_SUPPORTED", + "IM_USED", + "INSUFFICIENT_SPACE_ON_RESOURCE", + "INSUFFICIENT_STORAGE", + "INTERNAL_SERVER_ERROR", + "I_AM_A_TEAPOT", + "LENGTH_REQUIRED", + "LOCKED", + "LOOP_DETECTED", + "METHOD_FAILURE", + "METHOD_NOT_ALLOWED", + "MOVED_PERMANENTLY", + "MOVED_TEMPORARILY", + "MULTIPLE_CHOICES", + "MULTI_STATUS", + "NETWORK_AUTHENTICATION_REQUIRED", + "NON_AUTHORITATIVE_INFORMATION", + "NOT_ACCEPTABLE", + "NOT_EXTENDED", + "NOT_FOUND", + "NOT_IMPLEMENTED", + "NOT_MODIFIED", + "NO_CONTENT", + "OK", + "PARTIAL_CONTENT", + "PAYLOAD_TOO_LARGE", + "PAYMENT_REQUIRED", + "PERMANENT_REDIRECT", + "PRECONDITION_FAILED", + "PRECONDITION_REQUIRED", + "PROCESSING", + "PROXY_AUTHENTICATION_REQUIRED", + "REQUESTED_RANGE_NOT_SATISFIABLE", + "REQUEST_ENTITY_TOO_LARGE", + "REQUEST_HEADER_FIELDS_TOO_LARGE", + "REQUEST_TIMEOUT", + "REQUEST_URI_TOO_LONG", + "RESET_CONTENT", + "SEE_OTHER", + "SERVICE_UNAVAILABLE", + "SWITCHING_PROTOCOLS", + "TEMPORARY_REDIRECT", + "TOO_EARLY", + "TOO_MANY_REQUESTS", + "UNAUTHORIZED", + "UNAVAILABLE_FOR_LEGAL_REASONS", + "UNPROCESSABLE_ENTITY", + "UNSUPPORTED_MEDIA_TYPE", + "UPGRADE_REQUIRED", + "URI_TOO_LONG", + "USE_PROXY", + "VARIANT_ALSO_NEGOTIATES" + ] + }, + "statusCodeValue": { + "type": "integer", + "format": "int32" + } + }, + "title": "ResponseEntity" + }, + "RequestXPath": { + "type": "object", + "properties": { + "data": { + "type": "string", + "example": " Test1 Test3 ", + "description": "The XML data to be processed" + }, + "process": { + "type": "string", + "example": "count(//value)", + "description": "XPath tranform to be executed" + }, + "processor": { + "type": "string", + "enum": [ + "saxon", + "xalan" + ] + }, + "version": { + "type": "string", + "enum": [ + "2.0", + "3.0", + "3.1" + ] + } + } + }, + "RequestXSLT": { + "type": "object", + "properties": { + "data": { + "type": "string", + "example": " Test1 Test3 ", + "description": "The XML data to be processed" + }, + "process": { + "type": "string", + "example": "count(//value)", + "description": "XSLT tranform to be executed" + }, + "processor": { + "type": "string", + "enum": [ + "saxon", + "xalan" + ] + }, + "version": { + "type": "string", + "enum": [ + "2.0", + "3.0", + "3.1" + ] + } + } + }, + "RequestXSD": { + "type": "object", + "properties": { + "data": { + "type": "string", + "example": " Ola Nordmann Langgt 23 4000 Stavanger Norway ", + "description": "The XML data to be processed" + }, + "process": { + "type": "string", + "example": " Ola Nordmann Langgt 23 4000 Stavanger Norway ", + "description": "XSD to perform verification with" + }, + "processor": { + "type": "string", + "enum": [ + "saxon", + "xalan" + ] + }, + "version": { + "type": "string", + "enum": [ + "2.0", + "3.0", + "3.1" + ] + } + } + }, + "Response": { + "type": "object", + "properties": { + "result": { + "type": "string", + "example": "4", + "description": "Result of performing transformation on provided XML" + }, + "time": { + "type": "string", + "example": "320", + "description": "Computation time in milliseconds" + }, + "processor": { + "type": "string", + "enum": [ + "Saxon 10.3 2.0 over s9api", + "Xalan Java 2.7.2" + ] + }, + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + }, + "ResponseError": { + "type": "object", + "properties": { + "result": { + "type": "string", + "example": "Concatenation operator ('||') requires XPath 3.0 to be enabled", + "description": "Error from XPath processor" + }, + "time": { + "type": "string", + "example": "40", + "description": "Computation time in milliseconds" + }, + "processor": { + "type": "string", + "enum": [ + "Saxon 10.3 2.0 over s9api", + "Xalan Java 2.7.2" + ] + }, + "status": { + "type": "string", + "enum": [ + "ERR" + ] + } + } + }, + "XSDResponse": { + "type": "object", + "properties": { + "result": { + "type": "string", + "example": "XML file is valid", + "description": "Validation result" + }, + "time": { + "type": "string", + "example": "7", + "description": "Computation time in milliseconds" + }, + "processor": { + "type": "string", + "enum": [ + "Xalan Java 2.7.2" + ] + }, + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + }, + "XSDError": { + "type": "object", + "properties": { + "result": { + "type": "string", + "example": "The end-tag for element type \"xs:complexType\" must end with a '>' delimiter.", + "description": "Validation result" + }, + "time": { + "type": "string", + "example": "7", + "description": "Computation time in milliseconds" + }, + "processor": { + "type": "string", + "enum": [ + "Xalan Java 2.7.2" + ] + }, + "status": { + "type": "string", + "enum": [ + "ERR" + ] + } + } + } + }, + "externalDocs": { + "description": "Find out more about Swagger", + "url": "http://swagger.io" + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6524db5..baed536 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,17 @@ services: environment: SPRING_PROFILES_ACTIVE: DEV + swagger: + image: "swaggerapi/swagger-ui:latest" + container_name: xmltools-swagger + ports: + - "8000:8080" + environment: + - BASE_URL=/swagger + - SWAGGER_JSON=/Swagger/swagger.json + volumes: + - ./Swagger:/Swagger + networks: default: name: tools_network diff --git a/readme.md b/readme.md index c1a3e1b..30694c5 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,9 @@ Service is split into three microservices. Main page is hosted on port 8086. +## API Documentation +API documentation is available on port 8080/swagger/ + ## JavaSpark backend Backend is hosted by default on port 8081. Rest api documentation is contained in OpenApi document openapi.yml