Skip to content

Commit

Permalink
[VAS-936] updated openapi configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelemella committed Jul 15, 2024
1 parent 99aa070 commit 1dc1a68
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
15 changes: 13 additions & 2 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
"version" : "1.0.9"
},
"servers" : [ {
"url" : "${host}/gpd/payments/pull/api/v1"
"url" : "http://localhost:8080",
"description" : "Localhost base URL"
}, {
"url" : "https://{host}/gpd/payments/pull/api/v1",
"description" : "Base URL",
"variables" : {
"host" : {
"default" : "api.dev.platform.pagopa.it",
"enum" : [ "api.dev.platform.pagopa.it", "api.uat.platform.pagopa.it", "api.platform.pagopa.it" ]
}
}
} ],
"tags" : [ {
"name" : "Payment Notices",
Expand Down Expand Up @@ -408,7 +418,8 @@
"securitySchemes" : {
"ApiKey" : {
"type" : "apiKey",
"name" : "Ocp-Apim-Subscription-Key"
"name" : "Ocp-Apim-Subscription-Key",
"in" : "header"
}
}
}
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/it/gov/pagopa/gpd/payments/pull/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import it.gov.pagopa.gpd.payments.pull.models.ErrorResponse;
import org.eclipse.microprofile.openapi.annotations.Components;
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeIn;
import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeType;
import org.eclipse.microprofile.openapi.annotations.info.Info;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.ExampleObject;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.security.SecurityScheme;
import org.eclipse.microprofile.openapi.annotations.servers.Server;
import org.eclipse.microprofile.openapi.annotations.servers.ServerVariable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -22,13 +25,24 @@


@OpenAPIDefinition(
info = @Info(title = "GPD Payments Pull Services", version = "${quarkus.application.version}"),
servers = {
@Server(url = "http://localhost:8080", description = "Localhost base URL"),
@Server(url = "https://{host}/gpd/payments/pull/api/v1", description = "Base URL",
variables = {
@ServerVariable(name = "host",
enumeration = {"api.dev.platform.pagopa.it","api.uat.platform.pagopa.it","api.platform.pagopa.it"},
defaultValue = "api.dev.platform.pagopa.it")})
},
components =
@Components(
securitySchemes = {
@SecurityScheme(
securitySchemeName = "ApiKey",
apiKeyName = "Ocp-Apim-Subscription-Key",
type = SecuritySchemeType.APIKEY)
type = SecuritySchemeType.APIKEY,
in = SecuritySchemeIn.HEADER
)
},
responses = {
@APIResponse(
Expand Down Expand Up @@ -85,8 +99,7 @@
"detail": "Payment Notice [<pn_id>] not found",
"instance": "PPL_900"
}""")),
}),
info = @Info(title = "GPD Payments Pull Services", version = "${quarkus.application.version}"))
}))
@Startup
@QuarkusMain
public class App extends Application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class PaymentNotices {
content = @Content(mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(type = SchemaType.ARRAY, implementation = PaymentNotice.class))
),
@APIResponse(description = "Unexpected error occured while recovering payment notices",
@APIResponse(description = "Unexpected error occurred while recovering payment notices",
ref = "#/components/responses/InternalServerError"),
@APIResponse(description = "Invalid or missing dueDate parameter",
ref = "#/components/responses/AppException400"),
Expand All @@ -99,7 +99,7 @@ public Uni<Response> getPaymentNotices(
args.put("limit", limit);
args.put("page", page);

if(taxCode == null || taxCode.length() != FISCAL_CODE_LENGTH) {
if (taxCode == null || taxCode.length() != FISCAL_CODE_LENGTH) {
String errMsg = "Fiscal code " + taxCode + " header is null or not valid";
throw new InvalidTaxCodeHeaderException(AppErrorCodeEnum.PPL_601, errMsg);
}
Expand All @@ -108,7 +108,7 @@ public Uni<Response> getPaymentNotices(

Uni<List<PaymentNotice>> paymentNoticesUni = paymentNoticeService.getPaymentNotices(taxCode, dueDate, limit, page);
return paymentNoticesUni.onFailure().invoke(Unchecked.consumer(error -> {
if(error instanceof PaymentNoticeException ex)
if (error instanceof PaymentNoticeException ex)
throw new PaymentNoticeException(ex.getErrorCode(), ex.getMessage(), ex.getCause());
else
throw new AppErrorException(error);
Expand All @@ -128,6 +128,4 @@ public Uni<Response> getPaymentNotices(
return Response.ok().entity(item).build();
});
}


}
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ quarkus.smallrye-openapi.info-title=${quarkus.application.name} (${quarkus.appli
quarkus.smallrye-openapi.info-description=GPD Payments Pull Services
quarkus.smallrye-openapi.info-version=${quarkus.application.version}
quarkus.smallrye-openapi.info-terms-of-service=https://www.pagopa.gov.it/
quarkus.smallrye-openapi.servers=\\$\{host\}/gpd/payments/pull/api/v1
%dev.quarkus.smallrye-openapi.servers=
# Path for the Swagger endpoint and file
quarkus.swagger-ui.path=/swagger
Expand Down

0 comments on commit 1dc1a68

Please sign in to comment.