diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 044fdff..8240966 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -21,7 +21,7 @@ "get" : { "tags" : [ "broker-entity-controller" ], "description" : "get-broker", - "operationId" : "getCollectionResource-broker-get", + "operationId" : "crud-get-broker", "parameters" : [ { "name" : "page", "in" : "query", @@ -80,7 +80,7 @@ "post" : { "tags" : [ "broker-entity-controller" ], "description" : "create-broker", - "operationId" : "postCollectionResource-broker-post", + "operationId" : "crud-create-broker", "requestBody" : { "content" : { "application/json" : { @@ -108,7 +108,7 @@ "/crud/brokers/search/findByOrgFiscalCode" : { "get" : { "tags" : [ "broker-search-controller" ], - "operationId" : "executeSearch-broker-get", + "operationId" : "crud-brokers-findByOrgFiscalCode", "parameters" : [ { "name" : "orgFiscalCode", "in" : "query", @@ -137,7 +137,7 @@ "get" : { "tags" : [ "broker-entity-controller" ], "description" : "get-broker", - "operationId" : "getItemResource-broker-get", + "operationId" : "crud-get-broker_1", "parameters" : [ { "name" : "id", "in" : "path", @@ -165,7 +165,7 @@ "put" : { "tags" : [ "broker-entity-controller" ], "description" : "update-broker", - "operationId" : "putItemResource-broker-put", + "operationId" : "crud-update-broker", "parameters" : [ { "name" : "id", "in" : "path", @@ -213,7 +213,7 @@ "delete" : { "tags" : [ "broker-entity-controller" ], "description" : "delete-broker", - "operationId" : "deleteItemResource-broker-delete", + "operationId" : "crud-delete-broker", "parameters" : [ { "name" : "id", "in" : "path", @@ -234,7 +234,7 @@ "patch" : { "tags" : [ "broker-entity-controller" ], "description" : "patch-broker", - "operationId" : "patchItemResource-broker-patch", + "operationId" : "crud-patch-broker", "parameters" : [ { "name" : "id", "in" : "path", @@ -274,7 +274,7 @@ "get" : { "tags" : [ "organization-entity-controller" ], "description" : "get-organization", - "operationId" : "getCollectionResource-organization-get", + "operationId" : "crud-get-organization", "parameters" : [ { "name" : "page", "in" : "query", @@ -333,7 +333,7 @@ "post" : { "tags" : [ "organization-entity-controller" ], "description" : "create-organization", - "operationId" : "postCollectionResource-organization-post", + "operationId" : "crud-create-organization", "requestBody" : { "content" : { "application/json" : { @@ -361,7 +361,7 @@ "/crud/organizations/search/findByIpaCode" : { "get" : { "tags" : [ "organization-search-controller" ], - "operationId" : "executeSearch-organization-get", + "operationId" : "crud-organizations-findByIpaCode", "parameters" : [ { "name" : "ipaCode", "in" : "query", @@ -386,11 +386,39 @@ } } }, + "/crud/organizations/search/findByOrgFiscalCode" : { + "get" : { + "tags" : [ "organization-search-controller" ], + "operationId" : "crud-organizations-findByOrgFiscalCode", + "parameters" : [ { + "name" : "orgFiscalCode", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/Organization" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + } + }, "/crud/organizations/{id}" : { "get" : { "tags" : [ "organization-entity-controller" ], "description" : "get-organization", - "operationId" : "getItemResource-organization-get", + "operationId" : "crud-get-organization_1", "parameters" : [ { "name" : "id", "in" : "path", @@ -418,7 +446,7 @@ "put" : { "tags" : [ "organization-entity-controller" ], "description" : "update-organization", - "operationId" : "putItemResource-organization-put", + "operationId" : "crud-update-organization", "parameters" : [ { "name" : "id", "in" : "path", @@ -466,7 +494,7 @@ "delete" : { "tags" : [ "organization-entity-controller" ], "description" : "delete-organization", - "operationId" : "deleteItemResource-organization-delete", + "operationId" : "crud-delete-organization", "parameters" : [ { "name" : "id", "in" : "path", @@ -487,7 +515,7 @@ "patch" : { "tags" : [ "organization-entity-controller" ], "description" : "patch-organization", - "operationId" : "patchItemResource-organization-patch", + "operationId" : "crud-patch-organization", "parameters" : [ { "name" : "id", "in" : "path", @@ -526,7 +554,7 @@ "/crud/profile" : { "get" : { "tags" : [ "profile-controller" ], - "operationId" : "listAllFormsOfMetadata", + "operationId" : "crud-profile-profile", "responses" : { "200" : { "description" : "OK", @@ -544,7 +572,7 @@ "/crud/profile/brokers" : { "get" : { "tags" : [ "profile-controller" ], - "operationId" : "descriptor", + "operationId" : "crud-profile-brokers", "responses" : { "200" : { "description" : "OK", @@ -572,7 +600,7 @@ "/crud/profile/organizations" : { "get" : { "tags" : [ "profile-controller" ], - "operationId" : "descriptor_1", + "operationId" : "crud-profile-organizations", "responses" : { "200" : { "description" : "OK", @@ -743,113 +771,47 @@ } } }, - "Organization" : { + "Broker" : { "type" : "object", "properties" : { - "organizationId" : { + "brokerId" : { "type" : "integer", "format" : "int64" }, - "ipaCode" : { - "type" : "string" - }, - "orgFiscalCode" : { - "type" : "string" - }, - "orgName" : { - "type" : "string" - }, - "adminEmail" : { - "type" : "string" - }, - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "lastUpdateDate" : { - "type" : "string", - "format" : "date-time" - }, - "fee" : { + "organizationId" : { "type" : "integer", "format" : "int64" }, - "iban" : { - "type" : "string" - }, - "urlOrgSendSilPaymentResult" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "creditBicSeller" : { - "type" : "boolean" - }, - "beneficiaryOrgName" : { - "type" : "string" - }, - "beneficiaryOrgAddress" : { - "type" : "string" - }, - "beneficiaryOrgCivic" : { - "type" : "string" - }, - "beneficiaryOrgPostalCode" : { - "type" : "string" - }, - "beneficiaryOrgLocation" : { - "type" : "string" - }, - "beneficiaryOrgProvince" : { - "type" : "string" - }, - "beneficiaryOrgNation" : { - "type" : "string" - }, - "beneficiaryOrgPhoneNumber" : { - "type" : "string" - }, - "beneficiaryOrgWebSite" : { - "type" : "string" - }, - "beneficiaryOrgEmail" : { - "type" : "string" - }, - "applicationCode" : { - "type" : "string" - }, - "cbillInterBankCode" : { - "type" : "string" - }, - "orgInformation" : { + "brokerFiscalCode" : { "type" : "string" }, - "orgLogoDesc" : { + "brokerName" : { "type" : "string" }, - "authorizationDesc" : { - "type" : "string" + "pagoPaInteractionModel" : { + "type" : "string", + "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] }, - "status" : { + "stationId" : { "type" : "string" }, - "urlActiveExternal" : { + "broadcastStationId" : { "type" : "string" }, - "additionalLanguage" : { - "type" : "string" + "syncKey" : { + "type" : "string", + "format" : "byte" }, - "orgTypeCode" : { - "type" : "string" + "gpdKey" : { + "type" : "string", + "format" : "byte" }, - "startDate" : { + "acaKey" : { "type" : "string", - "format" : "date" + "format" : "byte" }, - "brokerId" : { - "type" : "integer", - "format" : "int64" + "personalisationFe" : { + "$ref" : "#/components/schemas/PersonalisationFe" }, "_links" : { "$ref" : "#/components/schemas/Links" @@ -877,16 +839,16 @@ } } }, - "PagedModelOrganization" : { + "PagedModelBroker" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "organizations" : { + "brokers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Organization" + "$ref" : "#/components/schemas/Broker" } } } @@ -925,63 +887,129 @@ } } }, - "Broker" : { + "Organization" : { "type" : "object", "properties" : { - "brokerId" : { + "organizationId" : { "type" : "integer", "format" : "int64" }, - "organizationId" : { + "ipaCode" : { + "type" : "string" + }, + "orgFiscalCode" : { + "type" : "string" + }, + "orgName" : { + "type" : "string" + }, + "adminEmail" : { + "type" : "string" + }, + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "lastUpdateDate" : { + "type" : "string", + "format" : "date-time" + }, + "fee" : { "type" : "integer", "format" : "int64" }, - "brokerFiscalCode" : { + "iban" : { "type" : "string" }, - "brokerName" : { + "urlOrgSendSilPaymentResult" : { "type" : "string" }, - "pagoPaInteractionModel" : { - "type" : "string", - "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] + "password" : { + "type" : "string" }, - "stationId" : { + "creditBicSeller" : { + "type" : "boolean" + }, + "beneficiaryOrgName" : { "type" : "string" }, - "broadcastStationId" : { + "beneficiaryOrgAddress" : { "type" : "string" }, - "syncKey" : { - "type" : "string", - "format" : "byte" + "beneficiaryOrgCivic" : { + "type" : "string" }, - "gpdKey" : { - "type" : "string", - "format" : "byte" + "beneficiaryOrgPostalCode" : { + "type" : "string" }, - "acaKey" : { + "beneficiaryOrgLocation" : { + "type" : "string" + }, + "beneficiaryOrgProvince" : { + "type" : "string" + }, + "beneficiaryOrgNation" : { + "type" : "string" + }, + "beneficiaryOrgPhoneNumber" : { + "type" : "string" + }, + "beneficiaryOrgWebSite" : { + "type" : "string" + }, + "beneficiaryOrgEmail" : { + "type" : "string" + }, + "applicationCode" : { + "type" : "string" + }, + "cbillInterBankCode" : { + "type" : "string" + }, + "orgInformation" : { + "type" : "string" + }, + "orgLogoDesc" : { + "type" : "string" + }, + "authorizationDesc" : { + "type" : "string" + }, + "status" : { + "type" : "string" + }, + "urlActiveExternal" : { + "type" : "string" + }, + "additionalLanguage" : { + "type" : "string" + }, + "orgTypeCode" : { + "type" : "string" + }, + "startDate" : { "type" : "string", - "format" : "byte" + "format" : "date" }, - "personalisationFe" : { - "$ref" : "#/components/schemas/PersonalisationFe" + "brokerId" : { + "type" : "integer", + "format" : "int64" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelBroker" : { + "PagedModelOrganization" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "brokers" : { + "organizations" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Broker" + "$ref" : "#/components/schemas/Organization" } } } diff --git a/src/main/java/it/gov/pagopa/pu/organization/config/RepositoryRestCustomConfiguration.java b/src/main/java/it/gov/pagopa/pu/organization/config/RepositoryRestCustomConfiguration.java index 0e32095..8cc0f1a 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/config/RepositoryRestCustomConfiguration.java +++ b/src/main/java/it/gov/pagopa/pu/organization/config/RepositoryRestCustomConfiguration.java @@ -2,26 +2,46 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.metamodel.EntityType; -import java.util.Set; +import org.apache.commons.lang3.StringUtils; +import org.springdoc.core.customizers.OpenApiCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import java.util.Set; + @Configuration public class RepositoryRestCustomConfiguration { - private EntityManager entityManager; - public RepositoryRestCustomConfiguration(EntityManager entityManager){ + private final EntityManager entityManager; + + public RepositoryRestCustomConfiguration(EntityManager entityManager) { this.entityManager = entityManager; } + @Bean public RepositoryRestConfigurer repositoryRestConfigurer() { - return RepositoryRestConfigurer.withConfig( config -> { + return RepositoryRestConfigurer.withConfig(config -> { Set> entities = entityManager.getMetamodel().getEntities(); config.exposeIdsFor(entities.stream() .map(EntityType::getJavaType) .toArray(Class[]::new)); - } ); + }); + } + + @Bean + public OpenApiCustomizer operationIdCustomizer() { + return openApi -> openApi.getPaths().entrySet().stream() + .filter(e -> e.getKey().startsWith("/crud/")) + .forEach(entry -> { + String[] paths = entry.getKey().split("/"); + entry.getValue().readOperations().forEach(operation -> operation.setOperationId( + "crud-" + + StringUtils.firstNonEmpty( + operation.getDescription(), + paths[2] + "-" + paths[paths.length - 1] + ))); + }); } } 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 a5a4577..2f981b0 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 @@ -10,5 +10,6 @@ public interface OrganizationRepository extends JpaRepository { Optional findByIpaCode(String ipaCode); + Optional findByOrgFiscalCode(String orgFiscalCode); }