diff --git a/helm/Chart.yaml b/helm/Chart.yaml index aa3025e6..6ea31676 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 2.12.0 -appVersion: 2.10.3 +version: 2.13.0 +appVersion: 2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2 dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 4c56d199..5d58d81d 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-calculator - tag: "2.10.3" + tag: "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 405f2bef..8b4d2cca 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-calculator - tag: "2.10.3" + tag: "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 475a66af..28e7210d 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-calculator - tag: "2.10.3" + tag: "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/generate_openapi_v1_v2.sh b/openapi/generate_openapi_v1_v2.sh new file mode 100644 index 00000000..228a14d0 --- /dev/null +++ b/openapi/generate_openapi_v1_v2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ "$(pwd)" =~ .*"openapi".* ]]; then + cd .. +fi + +mvn test -Dtest=OpenApiGenerationTest diff --git a/openapi/openapi-node.json b/openapi/openapi-node.json index 66a50ebc..9cb2cb8a 100644 --- a/openapi/openapi-node.json +++ b/openapi/openapi-node.json @@ -4,7 +4,7 @@ "title": "PagoPA API Calculator Logic for Node", "description": "Calculator Logic microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "2.10.3" + "version": "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" }, "servers": [ { diff --git a/openapi/openapi.json b/openapi/openapi.json index 361e22a5..5132b9ec 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "PagoPA API Calculator Logic", "description": "Calculator Logic microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "2.10.3" + "version": "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" }, "servers": [ { diff --git a/openapi/openapi_v1.json b/openapi/openapi_v1.json new file mode 100644 index 00000000..62ee9e69 --- /dev/null +++ b/openapi/openapi_v1.json @@ -0,0 +1,988 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "PagoPA API Calculator Logic", + "description" : "Calculator Logic microservice for pagoPA AFM", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" + }, + "servers" : [ { + "url" : "http://localhost/", + "description" : "Generated server url" + } ], + "tags" : [ { + "name" : "Calculator", + "description" : "Everything about Calculator business logic" + }, { + "name" : "Configuration", + "description" : "Utility Services" + }, { + "name" : "Actuator", + "description" : "Monitor and interact", + "externalDocs" : { + "description" : "Spring Boot Actuator Web API Documentation", + "url" : "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } ], + "paths" : { + "/actuator" : { + "get" : { + "tags" : [ "Actuator" ], + "summary" : "Actuator root web endpoint", + "operationId" : "links", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v3+json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/components/schemas/Link" + } + } + } + } + } + } + } + } + }, + "/actuator/health" : { + "get" : { + "tags" : [ "Actuator" ], + "summary" : "Actuator web endpoint 'health'", + "operationId" : "health", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json" : { + "schema" : { + "type" : "object" + } + } + } + } + } + } + }, + "/actuator/health/**" : { + "get" : { + "tags" : [ "Actuator" ], + "summary" : "Actuator web endpoint 'health-path'", + "operationId" : "health-path", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json" : { + "schema" : { + "type" : "object" + } + } + } + } + } + } + }, + "/actuator/info" : { + "get" : { + "tags" : [ "Actuator" ], + "summary" : "Actuator web endpoint 'info'", + "operationId" : "info", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json" : { + "schema" : { + "type" : "object" + } + } + } + } + } + } + }, + "/actuator/metrics" : { + "get" : { + "tags" : [ "Actuator" ], + "summary" : "Actuator web endpoint 'metrics'", + "operationId" : "metrics", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json" : { + "schema" : { + "type" : "object" + } + } + } + } + } + } + }, + "/actuator/metrics/{requiredMetricName}" : { + "get" : { + "tags" : [ "Actuator" ], + "summary" : "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId" : "metrics-requiredMetricName", + "parameters" : [ { + "name" : "requiredMetricName", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json" : { + "schema" : { + "type" : "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json" : { + "schema" : { + "type" : "object" + } + } + } + } + } + } + }, + "/configuration/bundles/add" : { + "post" : { + "tags" : [ "Configuration" ], + "operationId" : "addValidBundles", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/ValidBundle" + } + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + }, + "/configuration/bundles/delete" : { + "post" : { + "tags" : [ "Configuration" ], + "operationId" : "deleteValidBundles", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/ValidBundle" + } + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + }, + "/configuration/paymenttypes/add" : { + "post" : { + "tags" : [ "Configuration" ], + "operationId" : "addPaymentTypes", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PaymentType" + } + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + }, + "/configuration/paymenttypes/delete" : { + "post" : { + "tags" : [ "Configuration" ], + "operationId" : "deletePaymentTypes", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PaymentType" + } + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + }, + "/configuration/touchpoint/add" : { + "post" : { + "tags" : [ "Configuration" ], + "operationId" : "addTouchpoints", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Touchpoint" + } + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + }, + "/configuration/touchpoint/delete" : { + "post" : { + "tags" : [ "Configuration" ], + "operationId" : "deleteTouchpoints", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Touchpoint" + } + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + }, + "/fees" : { + "post" : { + "tags" : [ "Calculator" ], + "summary" : "Get taxpayer fees of all or specified idPSP", + "operationId" : "getFees", + "parameters" : [ { + "name" : "maxOccurrences", + "in" : "query", + "required" : false, + "schema" : { + "type" : "integer", + "format" : "int32", + "default" : 10 + } + }, { + "name" : "allCcp", + "in" : "query", + "description" : "Flag for the exclusion of Poste bundles: false -> excluded, true or null -> included", + "required" : false, + "schema" : { + "type" : "string", + "default" : "true" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PaymentOption" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/BundleOption" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "422" : { + "description" : "Unable to process the request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "429" : { + "description" : "Too many requests" + }, + "500" : { + "description" : "Service unavailable", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + } + }, + "/info" : { + "get" : { + "tags" : [ "Home" ], + "summary" : "health check", + "description" : "Return OK if application is started", + "operationId" : "healthCheck", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AppInfo" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + }, + "403" : { + "description" : "Forbidden" + }, + "429" : { + "description" : "Too many requests" + }, + "500" : { + "description" : "Service unavailable", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + } + }, + "/psps/{idPsp}/fees" : { + "post" : { + "tags" : [ "Calculator" ], + "summary" : "Get taxpayer fees of the specified idPSP", + "operationId" : "getFeesByPsp", + "parameters" : [ { + "name" : "idPsp", + "in" : "path", + "description" : "PSP identifier", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "maxOccurrences", + "in" : "query", + "required" : false, + "schema" : { + "type" : "integer", + "format" : "int32", + "default" : 10 + } + }, { + "name" : "allCcp", + "in" : "query", + "description" : "Flag for the exclusion of Poste bundles: false -> excluded, true or null -> included", + "required" : false, + "schema" : { + "type" : "string", + "default" : "true" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PaymentOptionByPsp" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/BundleOption" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "422" : { + "description" : "Unable to process the request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "429" : { + "description" : "Too many requests" + }, + "500" : { + "description" : "Service unavailable", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + } + } + }, + "components" : { + "schemas" : { + "AppInfo" : { + "type" : "object", + "properties" : { + "environment" : { + "type" : "string" + }, + "name" : { + "type" : "string" + }, + "version" : { + "type" : "string" + } + } + }, + "BundleOption" : { + "type" : "object", + "properties" : { + "belowThreshold" : { + "type" : "boolean", + "description" : "if true (the payment amount is lower than the threshold value) the bundles onus is not calculated (always false)" + }, + "bundleOptions" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Transfer" + } + } + } + }, + "CiBundle" : { + "type" : "object", + "properties" : { + "attributes" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/CiBundleAttribute" + } + }, + "ciFiscalCode" : { + "type" : "string" + }, + "id" : { + "type" : "string" + } + }, + "required" : [ "ciFiscalCode", "id" ] + }, + "CiBundleAttribute" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" + }, + "maxPaymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "transferCategory" : { + "type" : "string" + }, + "transferCategoryRelation" : { + "type" : "string", + "enum" : [ "EQUAL", "NOT_EQUAL" ] + } + }, + "required" : [ "id" ] + }, + "Link" : { + "type" : "object", + "properties" : { + "href" : { + "type" : "string" + }, + "templated" : { + "type" : "boolean" + } + } + }, + "PaymentOption" : { + "type" : "object", + "properties" : { + "bin" : { + "type" : "string" + }, + "idPspList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PspSearchCriteria" + } + }, + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "paymentMethod" : { + "type" : "string" + }, + "primaryCreditorInstitution" : { + "type" : "string" + }, + "touchpoint" : { + "type" : "string" + }, + "transferList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TransferListItem" + } + } + }, + "required" : [ "paymentAmount", "primaryCreditorInstitution", "transferList" ] + }, + "PaymentOptionByPsp" : { + "type" : "object", + "properties" : { + "bin" : { + "type" : "string" + }, + "idBrokerPsp" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "paymentMethod" : { + "type" : "string" + }, + "primaryCreditorInstitution" : { + "type" : "string" + }, + "touchpoint" : { + "type" : "string" + }, + "transferList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TransferListItem" + } + } + } + }, + "PaymentType" : { + "type" : "object", + "properties" : { + "createdDate" : { + "type" : "string", + "format" : "date-time" + }, + "id" : { + "type" : "string" + }, + "name" : { + "type" : "string" + } + }, + "required" : [ "id", "name" ] + }, + "ProblemJson" : { + "type" : "object", + "properties" : { + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" + }, + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 + }, + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + } + } + }, + "PspSearchCriteria" : { + "type" : "object", + "properties" : { + "idBrokerPsp" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "idPsp" : { + "type" : "string" + } + }, + "required" : [ "idPsp" ] + }, + "Touchpoint" : { + "type" : "object", + "properties" : { + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "id" : { + "type" : "string" + }, + "name" : { + "type" : "string" + } + } + }, + "Transfer" : { + "type" : "object", + "properties" : { + "abi" : { + "type" : "string" + }, + "bundleDescription" : { + "type" : "string" + }, + "bundleName" : { + "type" : "string" + }, + "idBrokerPsp" : { + "type" : "string" + }, + "idBundle" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "idCiBundle" : { + "type" : "string" + }, + "idPsp" : { + "type" : "string" + }, + "onUs" : { + "type" : "boolean" + }, + "paymentMethod" : { + "type" : "string" + }, + "primaryCiIncurredFee" : { + "type" : "integer", + "format" : "int64" + }, + "pspBusinessName" : { + "type" : "string" + }, + "taxPayerFee" : { + "type" : "integer", + "format" : "int64" + }, + "touchpoint" : { + "type" : "string" + } + } + }, + "TransferListItem" : { + "type" : "object", + "properties" : { + "creditorInstitution" : { + "type" : "string" + }, + "digitalStamp" : { + "type" : "boolean" + }, + "transferCategory" : { + "type" : "string" + } + } + }, + "ValidBundle" : { + "type" : "object", + "properties" : { + "abi" : { + "type" : "string" + }, + "ciBundleList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/CiBundle" + } + }, + "description" : { + "type" : "string" + }, + "digitalStamp" : { + "type" : "boolean" + }, + "digitalStampRestriction" : { + "type" : "boolean" + }, + "id" : { + "type" : "string" + }, + "idBrokerPsp" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "idPsp" : { + "type" : "string" + }, + "maxPaymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "minPaymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + }, + "onUs" : { + "type" : "boolean" + }, + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "paymentType" : { + "type" : "string" + }, + "pspBusinessName" : { + "type" : "string" + }, + "touchpoint" : { + "type" : "string" + }, + "transferCategoryList" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "type" : { + "type" : "string", + "enum" : [ "GLOBAL", "PUBLIC", "PRIVATE" ] + } + }, + "required" : [ "digitalStamp", "digitalStampRestriction" ] + } + }, + "securitySchemes" : { + "ApiKey" : { + "type" : "apiKey", + "description" : "The API key to access this function app.", + "name" : "Ocp-Apim-Subscription-Key", + "in" : "header" + } + } + } +} \ No newline at end of file diff --git a/openapi/openapi_v2.json b/openapi/openapi_v2.json new file mode 100644 index 00000000..0e5e498a --- /dev/null +++ b/openapi/openapi_v2.json @@ -0,0 +1,481 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "PagoPA API Calculator Logic", + "description" : "Calculator Logic microservice for pagoPA AFM", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2" + }, + "servers" : [ { + "url" : "http://localhost/", + "description" : "Generated server url" + } ], + "tags" : [ { + "name" : "Calculator", + "description" : "Everything about Calculator business logic" + } ], + "paths" : { + "/fees/multi" : { + "post" : { + "tags" : [ "Calculator" ], + "summary" : "Get taxpayer fees of all or specified idPSP with ECs contributions", + "operationId" : "getFeesMulti", + "parameters" : [ { + "name" : "maxOccurrences", + "in" : "query", + "required" : false, + "schema" : { + "type" : "integer", + "format" : "int32", + "default" : 10 + } + }, { + "name" : "allCcp", + "in" : "query", + "description" : "Flag for the exclusion of Poste bundles: false -> excluded, true or null -> included", + "required" : false, + "schema" : { + "type" : "string", + "default" : "true" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PaymentOption" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/BundleOption" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "422" : { + "description" : "Unable to process the request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "429" : { + "description" : "Too many requests" + }, + "500" : { + "description" : "Service unavailable", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + } + }, + "/info" : { + "get" : { + "tags" : [ "Home" ], + "summary" : "health check", + "description" : "Return OK if application is started", + "operationId" : "healthCheck", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AppInfo" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + }, + "403" : { + "description" : "Forbidden" + }, + "429" : { + "description" : "Too many requests" + }, + "500" : { + "description" : "Service unavailable", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + } + }, + "/psps/{idPsp}/fees/multi" : { + "post" : { + "tags" : [ "Calculator" ], + "summary" : "Get taxpayer fees of the specified idPSP with ECs contributions", + "operationId" : "getFeesByPspMulti", + "parameters" : [ { + "name" : "idPsp", + "in" : "path", + "description" : "PSP identifier", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "maxOccurrences", + "in" : "query", + "required" : false, + "schema" : { + "type" : "integer", + "format" : "int32", + "default" : 10 + } + }, { + "name" : "allCcp", + "in" : "query", + "description" : "Flag for the exclusion of Poste bundles: false -> excluded, true or null -> included", + "required" : false, + "schema" : { + "type" : "string", + "default" : "true" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PaymentOptionByPsp" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/BundleOption" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "422" : { + "description" : "Unable to process the request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "429" : { + "description" : "Too many requests" + }, + "500" : { + "description" : "Service unavailable", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + } + } + }, + "components" : { + "schemas" : { + "AppInfo" : { + "type" : "object", + "properties" : { + "environment" : { + "type" : "string" + }, + "name" : { + "type" : "string" + }, + "version" : { + "type" : "string" + } + } + }, + "BundleOption" : { + "type" : "object", + "properties" : { + "belowThreshold" : { + "type" : "boolean", + "description" : "if true (the payment amount is lower than the threshold value) the bundles onus is not calculated (always false)" + }, + "bundleOptions" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Transfer" + } + } + } + }, + "PaymentOption" : { + "type" : "object", + "properties" : { + "bin" : { + "type" : "string" + }, + "idPspList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PspSearchCriteria" + } + }, + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "paymentMethod" : { + "type" : "string" + }, + "primaryCreditorInstitution" : { + "type" : "string" + }, + "touchpoint" : { + "type" : "string" + }, + "transferList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TransferListItem" + } + } + }, + "required" : [ "paymentAmount", "primaryCreditorInstitution", "transferList" ] + }, + "PaymentOptionByPsp" : { + "type" : "object", + "properties" : { + "bin" : { + "type" : "string" + }, + "idBrokerPsp" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "paymentMethod" : { + "type" : "string" + }, + "primaryCreditorInstitution" : { + "type" : "string" + }, + "touchpoint" : { + "type" : "string" + }, + "transferList" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TransferListItem" + } + } + } + }, + "ProblemJson" : { + "type" : "object", + "properties" : { + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" + }, + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 + }, + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + } + } + }, + "PspSearchCriteria" : { + "type" : "object", + "properties" : { + "idBrokerPsp" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "idPsp" : { + "type" : "string" + } + }, + "required" : [ "idPsp" ] + }, + "Transfer" : { + "type" : "object", + "properties" : { + "abi" : { + "type" : "string" + }, + "bundleDescription" : { + "type" : "string" + }, + "bundleName" : { + "type" : "string" + }, + "idBrokerPsp" : { + "type" : "string" + }, + "idBundle" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "idCiBundle" : { + "type" : "string" + }, + "idPsp" : { + "type" : "string" + }, + "onUs" : { + "type" : "boolean" + }, + "paymentMethod" : { + "type" : "string" + }, + "primaryCiIncurredFee" : { + "type" : "integer", + "format" : "int64" + }, + "pspBusinessName" : { + "type" : "string" + }, + "taxPayerFee" : { + "type" : "integer", + "format" : "int64" + }, + "touchpoint" : { + "type" : "string" + } + } + }, + "TransferListItem" : { + "type" : "object", + "properties" : { + "creditorInstitution" : { + "type" : "string" + }, + "digitalStamp" : { + "type" : "boolean" + }, + "transferCategory" : { + "type" : "string" + } + } + } + }, + "securitySchemes" : { + "ApiKey" : { + "type" : "apiKey", + "description" : "The API key to access this function app.", + "name" : "Ocp-Apim-Subscription-Key", + "in" : "header" + } + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 11803f1f..046c293b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ it.gov.pagopa calculator - 2.10.3 + 2.10.3-1-PAGOPA-1172-sviluppo-carrello-multi-ente-definizione-interfacce-v-2 afm-calculator Calculator Logic microservice for pagoPA AFM @@ -176,6 +176,13 @@ + + + + src/test/resources + true + + org.springframework.boot diff --git a/src/main/java/it/gov/pagopa/afm/calculator/controller/CalculatorController.java b/src/main/java/it/gov/pagopa/afm/calculator/controller/CalculatorController.java index 2f48acf7..4cb29478 100644 --- a/src/main/java/it/gov/pagopa/afm/calculator/controller/CalculatorController.java +++ b/src/main/java/it/gov/pagopa/afm/calculator/controller/CalculatorController.java @@ -180,4 +180,156 @@ public BundleOption getFees( return calculatorService.calculate( paymentOption, maxOccurrences, StringUtils.isBlank(allCcp) || Boolean.parseBoolean(allCcp)); } + + @Operation( + summary = "Get taxpayer fees of the specified idPSP with ECs contributions", + security = {@SecurityRequirement(name = "ApiKey")}, + tags = {"Calculator"}) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "Ok", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BundleOption.class))), + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "401", + description = "Unauthorized", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "404", + description = "Not Found", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "422", + description = "Unable to process the request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "429", + description = "Too many requests", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "500", + description = "Service unavailable", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))) + }) + @PostMapping( + value = "/psps/{idPsp}/fees/multi", + produces = {MediaType.APPLICATION_JSON_VALUE}) + public BundleOption getFeesByPspMulti( + @Parameter(description = "PSP identifier", required = true) @PathVariable("idPsp") + String idPsp, + @RequestBody @Valid PaymentOptionByPsp paymentOptionByPsp, + @RequestParam(required = false, defaultValue = "10") Integer maxOccurrences, + @RequestParam(required = false, defaultValue = "true") + @Parameter( + description = + "Flag for the exclusion of Poste bundles: false -> excluded, true or null ->" + + " included") + String allCcp) { + PaymentOption paymentOption = + PaymentOption.builder() + .paymentAmount(paymentOptionByPsp.getPaymentAmount()) + .primaryCreditorInstitution(paymentOptionByPsp.getPrimaryCreditorInstitution()) + .paymentMethod(paymentOptionByPsp.getPaymentMethod()) + .touchpoint(paymentOptionByPsp.getTouchpoint()) + .idPspList( + List.of( + PspSearchCriteria.builder() + .idPsp(idPsp) + .idChannel(paymentOptionByPsp.getIdChannel()) + .idBrokerPsp(paymentOptionByPsp.getIdBrokerPsp()) + .build())) + .transferList(paymentOptionByPsp.getTransferList()) + .bin(paymentOptionByPsp.getBin()) + .build(); + return BundleOption.builder() + .belowThreshold(false) + .build(); + } + + @Operation( + summary = "Get taxpayer fees of all or specified idPSP with ECs contributions", + security = {@SecurityRequirement(name = "ApiKey")}, + tags = {"Calculator"}) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "Ok", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BundleOption.class))), + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "401", + description = "Unauthorized", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "404", + description = "Not Found", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "422", + description = "Unable to process the request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "429", + description = "Too many requests", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "500", + description = "Service unavailable", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))) + }) + @PostMapping( + value = "/fees/multi", + produces = {MediaType.APPLICATION_JSON_VALUE}) + public BundleOption getFeesMulti( + @RequestBody @Valid PaymentOption paymentOption, + @RequestParam(required = false, defaultValue = "10") Integer maxOccurrences, + @RequestParam(required = false, defaultValue = "true") + @Parameter( + description = + "Flag for the exclusion of Poste bundles: false -> excluded, true or null ->" + + " included") + String allCcp) { + return BundleOption.builder() + .belowThreshold(false) + .build(); + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index afd12f7e..4b13cd25 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -13,8 +13,15 @@ management.health.livenessState.enabled=true management.health.readinessState.enabled=true # Openapi -springdoc.writer-with-order-by-keys=true +springdoc.writer-with-order-by-keys=false springdoc.writer-with-default-pretty-printer=true +springdoc.api-docs.groups.enabled=true +springdoc.group-configs[0].group=v1 +springdoc.group-configs[0].displayName=API AFM-Calculator v1 +springdoc.group-configs[0].paths-to-exclude=/**/multi +springdoc.group-configs[1].group=v2 +springdoc.group-configs[1].displayName=API AFM-Calculator v2 +springdoc.group-configs[1].paths-to-match=/**/multi,/info # Server server.servlet.context-path=/ diff --git a/src/test/java/it/gov/pagopa/afm/calculator/OpenApiGenerationTest.java b/src/test/java/it/gov/pagopa/afm/calculator/OpenApiGenerationTest.java new file mode 100644 index 00000000..759dbe7e --- /dev/null +++ b/src/test/java/it/gov/pagopa/afm/calculator/OpenApiGenerationTest.java @@ -0,0 +1,55 @@ +package it.gov.pagopa.afm.calculator; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@SpringBootTest +@AutoConfigureMockMvc +class OpenApiGenerationTest { + + @Autowired + ObjectMapper objectMapper; + + @Autowired + private MockMvc mvc; + + @Test + void swaggerSpringPlugin() throws Exception { + saveOpenAPI("/v3/api-docs/v1/", "openapi_v1.json"); + saveOpenAPI("/v3/api-docs/v2/", "openapi_v2.json"); + } + + private void saveOpenAPI(String fromUri, String toFile) throws Exception { + mvc.perform(MockMvcRequestBuilders.get(fromUri).accept(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().is2xxSuccessful()) + .andDo( + (result) -> { + assertNotNull(result); + assertNotNull(result.getResponse()); + final String content = result.getResponse().getContentAsString(); + assertFalse(content.isBlank()); + assertFalse(content.contains("${"), "Generated swagger contains placeholders"); + Object swagger = + objectMapper.readValue(result.getResponse().getContentAsString(), Object.class); + String formatted = + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(swagger); + Path basePath = Paths.get("openapi/"); + Files.createDirectories(basePath); + Files.write(basePath.resolve(toFile), formatted.getBytes()); + }); + } +} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 8f3fb319..dee92202 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -42,3 +42,14 @@ payment.amount.threshold=0 # PSP Poste pspPoste.id=testIdPspPoste + +# Openapi +springdoc.writer-with-order-by-keys=false +springdoc.writer-with-default-pretty-printer=true +springdoc.api-docs.groups.enabled=true +springdoc.group-configs[0].group=v1 +springdoc.group-configs[0].displayName=API AFM-Calculator v1 +springdoc.group-configs[0].paths-to-exclude=/**/multi +springdoc.group-configs[1].group=v2 +springdoc.group-configs[1].displayName=API AFM-Calculator v2 +springdoc.group-configs[1].paths-to-match=/**/multi,/info