From 6ed9c646dfa0860f6249b5c02c9c8a6da0e00e35 Mon Sep 17 00:00:00 2001 From: Stephan Staeheli <stephan.staeheli@baloise.ch> Date: Fri, 29 Nov 2019 11:29:43 +0100 Subject: [PATCH 1/2] added a default constructor to ErrorResponse --- .../corellia/api/entities/ErrorResponse.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/java/ch/baloise/corellia/api/entities/ErrorResponse.java b/src/main/java/ch/baloise/corellia/api/entities/ErrorResponse.java index 02610c5..d271b4f 100644 --- a/src/main/java/ch/baloise/corellia/api/entities/ErrorResponse.java +++ b/src/main/java/ch/baloise/corellia/api/entities/ErrorResponse.java @@ -1,16 +1,14 @@ /** * Copyright 2016 SmartBear Software * - * 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 + * <p>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 + * <p>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 + * <p>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 ch.baloise.corellia.api.entities; @@ -18,28 +16,35 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyDescription; - -import javax.validation.constraints.NotNull; import java.util.List; +import javax.validation.constraints.NotNull; public class ErrorResponse { - @NotNull - private ErrorCause errorCause; + @NotNull private ErrorCause errorCause; @NotNull @JsonPropertyDescription("Information about the error") private String message; - @JsonPropertyDescription("In case of e.g. validation error, each validation error is represented by one detail message") + @JsonPropertyDescription( + "In case of e.g. validation error, each validation error is represented by one detail message") private List<String> detailMessages; - public ErrorResponse(@JsonProperty("errorCause") ErrorCause errorCause, @JsonProperty("message") String message) { + public ErrorResponse() { + super(); + } + + public ErrorResponse( + @JsonProperty("errorCause") ErrorCause errorCause, @JsonProperty("message") String message) { this(errorCause, message, null); } @JsonCreator - public ErrorResponse(@JsonProperty("errorCause") ErrorCause errorCause, @JsonProperty("message") String message, @JsonProperty("detailMessages") List<String> detailMessages) { + public ErrorResponse( + @JsonProperty("errorCause") ErrorCause errorCause, + @JsonProperty("message") String message, + @JsonProperty("detailMessages") List<String> detailMessages) { this.errorCause = errorCause; this.message = message; this.detailMessages = detailMessages; @@ -69,5 +74,9 @@ public void setDetailMessages(List<String> detailMessages) { this.detailMessages = detailMessages; } - public enum ErrorCause {httpClientError, httpClientErrorInputValidation, httpServerError} + public enum ErrorCause { + httpClientError, + httpClientErrorInputValidation, + httpServerError + } } From c054a664724b2f3f78abd395d17867f1d1c181ab Mon Sep 17 00:00:00 2001 From: Stephan Staeheli <stephan.staeheli@gmx.ch> Date: Fri, 29 Nov 2019 10:37:26 +0000 Subject: [PATCH 2/2] recreate openapi.json --- docs/openapi.json | 314 +++++++++++++++++++++++----------------------- 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/docs/openapi.json b/docs/openapi.json index daeb81f..7dcd4eb 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -13,12 +13,12 @@ "version" : "0.1.0" }, "paths" : { - "/contracts/v1/documents" : { + "/contracts/v1" : { "post" : { - "tags" : [ "documents" ], - "summary" : "Upload a document for a contract.", - "description" : "Please note that this operation needs to be called per document for a contract to be uploaded. The response contains a handle to the document. This handle should be provided with the contract to be uploaded via uploadContract", - "operationId" : "uploadDocumentV1", + "tags" : [ "contracts" ], + "summary" : "Upload a contract V1 to the insurer.", + "description" : "Uploads a contract. If validation fails processing is refused, a corresponding error is thrown", + "operationId" : "uploadContractV1", "parameters" : [ { "name" : "X-Caller-Name", "in" : "header", @@ -40,11 +40,11 @@ } } ], "requestBody" : { - "description" : "a documnent that is part of a contract", + "description" : "Contract that needs to be uploaded to the insurer", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/Document" + "$ref" : "#/components/schemas/ContractV1" } } }, @@ -52,17 +52,17 @@ }, "responses" : { "default" : { - "description" : "A handle for the uploaded document which can be used in providing a new contract via POST contracts", + "description" : "A handle to the contract for conversation with the insurer is provided", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/FileHandle" + "$ref" : "#/components/schemas/ContractReference" } } } }, "400" : { - "description" : "Invalid document is provided. See ErrorResponse for more information about validation issues", + "description" : "Invalid contract is provided. See ErrorResponse for more information about validation issues", "content" : { "application/json; charset=UTF-8" : { "schema" : { @@ -84,12 +84,12 @@ } } }, - "/contracts/v2/documents" : { + "/contracts/v2" : { "post" : { - "tags" : [ "documents" ], - "summary" : "Upload a document for a contract.", - "description" : "Please note that this operation needs to be called per document for a contract to be uploaded. The response contains a handle to the document. This handle should be provided with the contract to be uploaded via uploadContract", - "operationId" : "uploadDocument", + "tags" : [ "contracts" ], + "summary" : "Upload a contract to the insurer.", + "description" : "Uploads a contract. If validation fails processing is refused, a corresponding error is thrown", + "operationId" : "uploadContract", "parameters" : [ { "name" : "X-Caller-Name", "in" : "header", @@ -111,11 +111,11 @@ } } ], "requestBody" : { - "description" : "a documnent that is part of a contract", + "description" : "Contract that needs to be uploaded to the insurer", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/Document" + "$ref" : "#/components/schemas/Contract" } } }, @@ -123,27 +123,17 @@ }, "responses" : { "default" : { - "description" : "A handle for the uploaded document which can be used in providing a new contract via POST contracts", + "description" : "A handle to the contract for conversation with the insurer is provided", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/FileHandle" + "$ref" : "#/components/schemas/ContractReference" } } } }, "400" : { - "description" : "Invalid document is provided. See ErrorResponse for more information about validation issues", - "content" : { - "application/json; charset=UTF-8" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "503" : { - "description" : "Technical issue on server side, please retry later", + "description" : "Invalid contract is provided. See ErrorResponse for more information about validation issues", "content" : { "application/json; charset=UTF-8" : { "schema" : { @@ -151,26 +141,6 @@ } } } - } - } - } - }, - "/contracts/v1/version" : { - "get" : { - "tags" : [ "version" ], - "summary" : "Callable way of retrieving current API version (following semver)", - "description" : "Endpoint to retrieve the current API version (following semver). Can be compared to the URI version. Can be used for testing purposes.", - "operationId" : "versionV1", - "responses" : { - "default" : { - "description" : "Version identifier", - "content" : { - "application/json; charset=UTF-8" : { - "schema" : { - "$ref" : "#/components/schemas/Version" - } - } - } }, "503" : { "description" : "Technical issue on server side, please retry later", @@ -185,12 +155,12 @@ } } }, - "/contracts/v2/cancellations" : { + "/contracts/v1/documents" : { "post" : { - "tags" : [ "contracts" ], - "summary" : "cancel a contract", - "description" : "cancels a contract. If validation fails processing is refused, a corresponding error is thrown", - "operationId" : "cancelContract", + "tags" : [ "documents" ], + "summary" : "Upload a document for a contract.", + "description" : "Please note that this operation needs to be called per document for a contract to be uploaded. The response contains a handle to the document. This handle should be provided with the contract to be uploaded via uploadContract", + "operationId" : "uploadDocumentV1", "parameters" : [ { "name" : "X-Caller-Name", "in" : "header", @@ -212,11 +182,11 @@ } } ], "requestBody" : { - "description" : "Cancellation to instruct the insurer to cancel the contract", + "description" : "a documnent that is part of a contract", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/Cancellation" + "$ref" : "#/components/schemas/Document" } } }, @@ -224,17 +194,17 @@ }, "responses" : { "default" : { - "description" : "A handle to the contract which was cancelled. It's intended for conversation between consumer and insurer", + "description" : "A handle for the uploaded document which can be used in providing a new contract via POST contracts", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/ContractReference" + "$ref" : "#/components/schemas/FileHandle" } } } }, "400" : { - "description" : "Invalid cancellation is provided. See ErrorResponse for more information about validation issues", + "description" : "Invalid document is provided. See ErrorResponse for more information about validation issues", "content" : { "application/json; charset=UTF-8" : { "schema" : { @@ -256,12 +226,12 @@ } } }, - "/contracts/v1" : { + "/contracts/v2/documents" : { "post" : { - "tags" : [ "contracts" ], - "summary" : "Upload a contract V1 to the insurer.", - "description" : "Uploads a contract. If validation fails processing is refused, a corresponding error is thrown", - "operationId" : "uploadContractV1", + "tags" : [ "documents" ], + "summary" : "Upload a document for a contract.", + "description" : "Please note that this operation needs to be called per document for a contract to be uploaded. The response contains a handle to the document. This handle should be provided with the contract to be uploaded via uploadContract", + "operationId" : "uploadDocument", "parameters" : [ { "name" : "X-Caller-Name", "in" : "header", @@ -283,11 +253,11 @@ } } ], "requestBody" : { - "description" : "Contract that needs to be uploaded to the insurer", + "description" : "a documnent that is part of a contract", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/ContractV1" + "$ref" : "#/components/schemas/Document" } } }, @@ -295,17 +265,17 @@ }, "responses" : { "default" : { - "description" : "A handle to the contract for conversation with the insurer is provided", + "description" : "A handle for the uploaded document which can be used in providing a new contract via POST contracts", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/ContractReference" + "$ref" : "#/components/schemas/FileHandle" } } } }, "400" : { - "description" : "Invalid contract is provided. See ErrorResponse for more information about validation issues", + "description" : "Invalid document is provided. See ErrorResponse for more information about validation issues", "content" : { "application/json; charset=UTF-8" : { "schema" : { @@ -327,12 +297,42 @@ } } }, - "/contracts/v2" : { + "/contracts/v1/version" : { + "get" : { + "tags" : [ "version" ], + "summary" : "Callable way of retrieving current API version (following semver)", + "description" : "Endpoint to retrieve the current API version (following semver). Can be compared to the URI version. Can be used for testing purposes.", + "operationId" : "versionV1", + "responses" : { + "default" : { + "description" : "Version identifier", + "content" : { + "application/json; charset=UTF-8" : { + "schema" : { + "$ref" : "#/components/schemas/Version" + } + } + } + }, + "503" : { + "description" : "Technical issue on server side, please retry later", + "content" : { + "application/json; charset=UTF-8" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/contracts/v2/cancellations" : { "post" : { "tags" : [ "contracts" ], - "summary" : "Upload a contract to the insurer.", - "description" : "Uploads a contract. If validation fails processing is refused, a corresponding error is thrown", - "operationId" : "uploadContract", + "summary" : "cancel a contract", + "description" : "cancels a contract. If validation fails processing is refused, a corresponding error is thrown", + "operationId" : "cancelContract", "parameters" : [ { "name" : "X-Caller-Name", "in" : "header", @@ -354,11 +354,11 @@ } } ], "requestBody" : { - "description" : "Contract that needs to be uploaded to the insurer", + "description" : "Cancellation to instruct the insurer to cancel the contract", "content" : { "application/json; charset=UTF-8" : { "schema" : { - "$ref" : "#/components/schemas/Contract" + "$ref" : "#/components/schemas/Cancellation" } } }, @@ -366,7 +366,7 @@ }, "responses" : { "default" : { - "description" : "A handle to the contract for conversation with the insurer is provided", + "description" : "A handle to the contract which was cancelled. It's intended for conversation between consumer and insurer", "content" : { "application/json; charset=UTF-8" : { "schema" : { @@ -376,7 +376,7 @@ } }, "400" : { - "description" : "Invalid contract is provided. See ErrorResponse for more information about validation issues", + "description" : "Invalid cancellation is provided. See ErrorResponse for more information about validation issues", "content" : { "application/json; charset=UTF-8" : { "schema" : { @@ -431,13 +431,12 @@ }, "components" : { "schemas" : { - "FileHandle" : { - "required" : [ "handle" ], + "ContractReference" : { "type" : "object", "properties" : { - "handle" : { + "reference" : { "type" : "string", - "description" : "Reference to an uploaded document. This can be a PDF or a picture (e.g. JPG) of a contract or a purchase receipt." + "description" : "Under this reference the contract is stored at the insurer" } } }, @@ -462,81 +461,6 @@ } } }, - "Document" : { - "required" : [ "contractId", "data", "documentType", "fileName", "mediaType" ], - "type" : "object", - "properties" : { - "data" : { - "type" : "array", - "description" : "The document itself", - "items" : { - "type" : "string", - "format" : "byte" - } - }, - "contractId" : { - "maxLength" : 20, - "minLength" : 0, - "type" : "string", - "description" : "The contract this document belongs to" - }, - "mediaType" : { - "type" : "string", - "description" : "Accepted media types for documents represented by data byte[]", - "enum" : [ "APPLICATION_PDF", "IMAGE_JPEG", "IMAGE_TIFF", "IMAGE_PNG", "IMAGE_BMP", "IMAGE_GIF" ] - }, - "fileName" : { - "maxLength" : 256, - "minLength" : 0, - "type" : "string" - }, - "documentType" : { - "type" : "string", - "enum" : [ "CONTRACT", "RECEIPT", "COVER_LETTER" ] - } - } - }, - "Version" : { - "required" : [ "value" ], - "type" : "object", - "properties" : { - "value" : { - "type" : "string", - "description" : "Version identifier of the current API definition" - } - } - }, - "ContractReference" : { - "type" : "object", - "properties" : { - "reference" : { - "type" : "string", - "description" : "Under this reference the contract is stored at the insurer" - } - } - }, - "Cancellation" : { - "required" : [ "contractId", "effectiveDate", "reasonCode" ], - "type" : "object", - "properties" : { - "contractId" : { - "maxLength" : 20, - "minLength" : 0, - "type" : "string", - "description" : "Id given by SaaS provider. Identifies the contract which should be cancelled" - }, - "effectiveDate" : { - "type" : "string", - "description" : "effecitve date of cancellation", - "format" : "date" - }, - "reasonCode" : { - "type" : "integer", - "description" : "A code uniquely identifying the cancellation reason", - "format" : "int32" - } - } - }, "Address" : { "required" : [ "city", "houseNumber", "street", "zipCode" ], "type" : "object", @@ -743,6 +667,16 @@ } } }, + "FileHandle" : { + "required" : [ "handle" ], + "type" : "object", + "properties" : { + "handle" : { + "type" : "string", + "description" : "Reference to an uploaded document. This can be a PDF or a picture (e.g. JPG) of a contract or a purchase receipt." + } + } + }, "MonetaryAmount" : { "required" : [ "amount" ], "type" : "object", @@ -1002,6 +936,72 @@ "format" : "int32" } } + }, + "Document" : { + "required" : [ "contractId", "data", "documentType", "fileName", "mediaType" ], + "type" : "object", + "properties" : { + "data" : { + "type" : "array", + "description" : "The document itself", + "items" : { + "type" : "string", + "format" : "byte" + } + }, + "contractId" : { + "maxLength" : 20, + "minLength" : 0, + "type" : "string", + "description" : "The contract this document belongs to" + }, + "mediaType" : { + "type" : "string", + "description" : "Accepted media types for documents represented by data byte[]", + "enum" : [ "APPLICATION_PDF", "IMAGE_JPEG", "IMAGE_TIFF", "IMAGE_PNG", "IMAGE_BMP", "IMAGE_GIF" ] + }, + "fileName" : { + "maxLength" : 256, + "minLength" : 0, + "type" : "string" + }, + "documentType" : { + "type" : "string", + "enum" : [ "CONTRACT", "RECEIPT", "COVER_LETTER" ] + } + } + }, + "Version" : { + "required" : [ "value" ], + "type" : "object", + "properties" : { + "value" : { + "type" : "string", + "description" : "Version identifier of the current API definition" + } + } + }, + "Cancellation" : { + "required" : [ "contractId", "effectiveDate", "reasonCode" ], + "type" : "object", + "properties" : { + "contractId" : { + "maxLength" : 20, + "minLength" : 0, + "type" : "string", + "description" : "Id given by SaaS provider. Identifies the contract which should be cancelled" + }, + "effectiveDate" : { + "type" : "string", + "description" : "effecitve date of cancellation", + "format" : "date" + }, + "reasonCode" : { + "type" : "integer", + "description" : "A code uniquely identifying the cancellation reason", + "format" : "int32" + } + } } } }