diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 2ffc00f..42eedf6 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -17,7 +17,7 @@ "description" : "the Broker API" } ], "paths" : { - "/brokers" : { + "/crud/brokers" : { "get" : { "tags" : [ "broker-entity-controller" ], "description" : "get-broker", @@ -105,7 +105,7 @@ } } }, - "/brokers/search/findByOrgFiscalCode" : { + "/crud/brokers/search/findByOrgFiscalCode" : { "get" : { "tags" : [ "broker-search-controller" ], "operationId" : "executeSearch-broker-get", @@ -133,7 +133,7 @@ } } }, - "/brokers/{id}" : { + "/crud/brokers/{id}" : { "get" : { "tags" : [ "broker-entity-controller" ], "description" : "get-broker", @@ -270,7 +270,7 @@ } } }, - "/organizations" : { + "/crud/organizations" : { "get" : { "tags" : [ "organization-entity-controller" ], "description" : "get-organization", @@ -358,7 +358,7 @@ } } }, - "/organizations/search/findByIpaCode" : { + "/crud/organizations/search/findByIpaCode" : { "get" : { "tags" : [ "organization-search-controller" ], "operationId" : "executeSearch-organization-get", @@ -386,7 +386,7 @@ } } }, - "/organizations/{id}" : { + "/crud/organizations/{id}" : { "get" : { "tags" : [ "organization-entity-controller" ], "description" : "get-organization", @@ -523,7 +523,7 @@ } } }, - "/profile" : { + "/crud/profile" : { "get" : { "tags" : [ "profile-controller" ], "operationId" : "listAllFormsOfMetadata", @@ -541,7 +541,7 @@ } } }, - "/profile/brokers" : { + "/crud/profile/brokers" : { "get" : { "tags" : [ "profile-controller" ], "operationId" : "descriptor", @@ -569,7 +569,7 @@ } } }, - "/profile/organizations" : { + "/crud/profile/organizations" : { "get" : { "tags" : [ "profile-controller" ], "operationId" : "descriptor_1", @@ -743,122 +743,6 @@ } } }, - "EntityModelBroker" : { - "type" : "object", - "properties" : { - "brokerId" : { - "type" : "integer", - "format" : "int64" - }, - "organizationId" : { - "type" : "integer", - "format" : "int64" - }, - "brokerFiscalCode" : { - "type" : "string" - }, - "brokerName" : { - "type" : "string" - }, - "pagoPaInteractionModel" : { - "type" : "string", - "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] - }, - "stationId" : { - "type" : "string" - }, - "broadcastStationId" : { - "type" : "string" - }, - "syncKey" : { - "type" : "string", - "format" : "byte" - }, - "gpdKey" : { - "type" : "string", - "format" : "byte" - }, - "acaKey" : { - "type" : "string", - "format" : "byte" - }, - "personalisationFe" : { - "$ref" : "#/components/schemas/PersonalisationFe" - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PageMetadata" : { - "type" : "object", - "properties" : { - "size" : { - "type" : "integer", - "format" : "int64" - }, - "totalElements" : { - "type" : "integer", - "format" : "int64" - }, - "totalPages" : { - "type" : "integer", - "format" : "int64" - }, - "number" : { - "type" : "integer", - "format" : "int64" - } - } - }, - "PagedModelEntityModelBroker" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "broker" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/EntityModelBroker" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" - } - } - }, - "PersonalisationFe" : { - "type" : "object", - "properties" : { - "headerAssistanceUrl" : { - "type" : "string" - }, - "logoFooterImg" : { - "type" : "string" - }, - "footerDescText" : { - "type" : "string" - }, - "footerPrivacyInfoUrl" : { - "type" : "string" - }, - "footerGDPRUrl" : { - "type" : "string" - }, - "footerTermsCondUrl" : { - "type" : "string" - }, - "footerAccessibilityUrl" : { - "type" : "string" - } - } - }, "EntityModelOrganization" : { "type" : "object", "properties" : { @@ -972,13 +856,34 @@ } } }, + "PageMetadata" : { + "type" : "object", + "properties" : { + "size" : { + "type" : "integer", + "format" : "int64" + }, + "totalElements" : { + "type" : "integer", + "format" : "int64" + }, + "totalPages" : { + "type" : "integer", + "format" : "int64" + }, + "number" : { + "type" : "integer", + "format" : "int64" + } + } + }, "PagedModelEntityModelOrganization" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "organization" : { + "organizations" : { "type" : "array", "items" : { "$ref" : "#/components/schemas/EntityModelOrganization" @@ -994,6 +899,101 @@ } } }, + "EntityModelBroker" : { + "type" : "object", + "properties" : { + "brokerId" : { + "type" : "integer", + "format" : "int64" + }, + "organizationId" : { + "type" : "integer", + "format" : "int64" + }, + "brokerFiscalCode" : { + "type" : "string" + }, + "brokerName" : { + "type" : "string" + }, + "pagoPaInteractionModel" : { + "type" : "string", + "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] + }, + "stationId" : { + "type" : "string" + }, + "broadcastStationId" : { + "type" : "string" + }, + "syncKey" : { + "type" : "string", + "format" : "byte" + }, + "gpdKey" : { + "type" : "string", + "format" : "byte" + }, + "acaKey" : { + "type" : "string", + "format" : "byte" + }, + "personalisationFe" : { + "$ref" : "#/components/schemas/PersonalisationFe" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PersonalisationFe" : { + "type" : "object", + "properties" : { + "headerAssistanceUrl" : { + "type" : "string" + }, + "logoFooterImg" : { + "type" : "string" + }, + "footerDescText" : { + "type" : "string" + }, + "footerPrivacyInfoUrl" : { + "type" : "string" + }, + "footerGDPRUrl" : { + "type" : "string" + }, + "footerTermsCondUrl" : { + "type" : "string" + }, + "footerAccessibilityUrl" : { + "type" : "string" + } + } + }, + "PagedModelEntityModelBroker" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "brokers" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/EntityModelBroker" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, "BrokerRequestBody" : { "type" : "object", "properties" : { @@ -1200,4 +1200,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/BrokerRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/BrokerRepository.java index 6b7ab60..e6c9113 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/BrokerRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/BrokerRepository.java @@ -7,7 +7,7 @@ import java.util.Optional; -@RepositoryRestResource(collectionResourceRel = "broker", path = "brokers") +@RepositoryRestResource(path = "brokers") public interface BrokerRepository extends JpaRepository { @Query("select b from broker b join Organization o on b.brokerId = o.brokerId " + diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java index f6da89d..a5a4577 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java @@ -6,7 +6,7 @@ import java.util.Optional; -@RepositoryRestResource(path = "organizations", collectionResourceRel = "organization") +@RepositoryRestResource(path = "organizations") public interface OrganizationRepository extends JpaRepository { Optional findByIpaCode(String ipaCode); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5391d08..5ce2831 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,6 +8,9 @@ spring: username: "\${ORGANIZATION_DB_USER}" password: "\${ORGANIZATION_DB_PASSWORD}" driverClassName: org.postgresql.Driver + data: + rest: + basePath: crud management: endpoint: diff --git a/src/test/java/it/gov/pagopa/pu/organization/OpenApiGeneratorTest.java b/src/test/java/it/gov/pagopa/pu/organization/OpenApiGeneratorTest.java index 27fd4d3..73e0d95 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/OpenApiGeneratorTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/OpenApiGeneratorTest.java @@ -38,29 +38,27 @@ class OpenApiGeneratorTest { @Test void generateAndVerifyCommit() throws Exception { MvcResult result = mockMvc.perform( - get("/v3/api-docs") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON) - ).andExpect(status().isOk()) + get("/v3/api-docs") + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + ).andExpect(status().isOk()) .andReturn(); - String openApiResult = result.getResponse().getContentAsString() - .replace("\r", ""); - + String openApiResult = result.getResponse().getContentAsString().replace("\r", ""); Assertions.assertTrue(openApiResult.startsWith("{\n \"openapi\" : \"3.0.")); Path openApiGeneratedPath = Path.of("openapi/generated.openapi.json"); - boolean toStore=true; - if(Files.exists(openApiGeneratedPath)){ + boolean toStore = true; + if (Files.exists(openApiGeneratedPath)) { String storedOpenApi = Files.readString(openApiGeneratedPath); try { content().json(storedOpenApi, JsonCompareMode.STRICT).match(result); - toStore=false; - } catch (Throwable e){ + toStore = false; + } catch (Throwable e) { //Do Nothing } } - if(toStore){ + if (toStore) { Files.writeString(openApiGeneratedPath, openApiResult, StandardOpenOption.TRUNCATE_EXISTING); }