From 51bdd66f360b696ef6f5a728062ee4800a25aa15 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Wed, 10 May 2023 13:55:47 +0200 Subject: [PATCH 1/5] feat(api): Specify JSON content type as response --- .../eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt | 7 ++++--- .../tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt | 3 ++- .../eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt | 4 ++-- .../tractusx/bpdm/gate/api/GateLegalEntityApi.kt | 3 ++- .../org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt | 3 ++- .../eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt | 4 +++- .../org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt | 6 +++--- .../tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt | 6 +++--- .../tractusx/bpdm/pool/api/PoolLegalEntityApi.kt | 3 ++- .../eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt | 3 ++- .../tractusx/bpdm/pool/api/PoolOpenSearchApi.kt | 7 ++++--- .../org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt | 10 +++++----- .../org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt | 10 +++++----- .../tractusx/bpdm/pool/api/PoolSuggestionApi.kt | 4 +++- 14 files changed, 42 insertions(+), 31 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt index e10585d2f..a5e8b42a2 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt @@ -33,6 +33,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange @@ -40,7 +41,7 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange import org.springframework.web.service.annotation.PutExchange -@RequestMapping("/api/catena") +@RequestMapping("/api/catena", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena") interface GateAddressApi { @@ -60,7 +61,7 @@ interface GateAddressApi { ) @PutMapping("/input/addresses") @PutExchange("/input/addresses") - fun upsertAddresses (@RequestBody addresses: Collection): ResponseEntity + fun upsertAddresses(@RequestBody addresses: Collection): ResponseEntity @Operation( @@ -124,7 +125,7 @@ interface GateAddressApi { @PostExchange("/output/addresses/search") fun getAddressesOutput( @ParameterObject @Valid paginationRequest: PaginationStartAfterRequest, - @RequestBody (required = false) externalIds: Collection? + @RequestBody(required = false) externalIds: Collection? ): PageOutputResponse @Operation( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt index 0f0ff016d..2385425ae 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt @@ -25,13 +25,14 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/catena/business-partners") +@RequestMapping("/api/catena/business-partners", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/business-partners") interface GateBusinessPartnerApi { diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index 5b3bcddbe..f41a85c23 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -1,4 +1,3 @@ - /******************************************************************************* * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation * @@ -33,12 +32,13 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange import java.time.Instant -@RequestMapping("/api/catena/business-partners/changelog") +@RequestMapping("/api/catena/business-partners/changelog", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/business-partners/changelog") interface GateChangelogApi { diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 251e40ea9..196cdbe9c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -33,6 +33,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange @@ -40,7 +41,7 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange import org.springframework.web.service.annotation.PutExchange -@RequestMapping("/api/catena") +@RequestMapping("/api/catena", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena") interface GateLegalEntityApi { diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index 5684b46c0..aeebdd32c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -33,6 +33,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange @@ -40,7 +41,7 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange import org.springframework.web.service.annotation.PutExchange -@RequestMapping("/api/catena") +@RequestMapping("/api/catena", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena") interface GateSiteApi { diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt index 4754f0803..34eca8eba 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt @@ -33,6 +33,7 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequ import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerUpdateRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.* import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange import org.springframework.web.service.annotation.HttpExchange @@ -40,7 +41,7 @@ import org.springframework.web.service.annotation.PostExchange import org.springframework.web.service.annotation.PutExchange -@RequestMapping("/api/catena/addresses") +@RequestMapping("/api/catena/addresses", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/addresses") interface PoolAddressApi { @@ -80,6 +81,7 @@ interface PoolAddressApi { fun getAddress( @Parameter(description = "Bpn value") @PathVariable bpn: String ): LogisticAddressResponse + @Operation( summary = "Search address partners by BPNs and/or parent BPNs", description = "Search business partners of type address by their BPN or their parent partners BPN (BPNLs or BPNS)." diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt index 05e007e4e..09412c9de 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt @@ -20,13 +20,13 @@ package org.eclipse.tractusx.bpdm.pool.api - import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.pool.api.model.request.IdentifiersSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody @@ -34,9 +34,9 @@ import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/catena/bpn") +@RequestMapping("/api/catena/bpn", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/bpn") -interface PoolBpnApi { +interface PoolBpnApi { @Operation( summary = "Find business partner numbers by identifiers", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt index 24df41800..da540a523 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.pool.api - import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Content @@ -30,6 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam @@ -37,9 +37,9 @@ import org.springframework.web.service.annotation.GetExchange import org.springframework.web.service.annotation.HttpExchange import java.time.Instant -@RequestMapping("/api/catena/business-partners") +@RequestMapping("/api/catena/business-partners", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/business-partners") -interface PoolBusinessPartnerApi { +interface PoolBusinessPartnerApi { @Operation( summary = "Get business partner changelog entries by bpn", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt index be4423878..7a42eb5a1 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt @@ -31,6 +31,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.pool.api.model.request.* import org.eclipse.tractusx.bpdm.pool.api.model.response.* import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange @@ -38,7 +39,7 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange import org.springframework.web.service.annotation.PutExchange -@RequestMapping("/api/catena/legal-entities") +@RequestMapping("/api/catena/legal-entities", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/legal-entities") interface PoolLegalEntityApi { diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt index 54c860cac..b62fe89dd 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt @@ -33,6 +33,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange @@ -40,7 +41,7 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/catena") +@RequestMapping("/api/catena", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena") interface PoolMetadataApi { diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt index ea4f41b0f..2046234c0 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt @@ -20,12 +20,12 @@ package org.eclipse.tractusx.bpdm.pool.api - import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping @@ -36,9 +36,9 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/opensearch") +@RequestMapping("/api/opensearch", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/opensearch") -interface PoolOpenSearchApi { +interface PoolOpenSearchApi { @Operation( summary = "Index new business partner records on OpenSearch", @@ -54,6 +54,7 @@ interface PoolOpenSearchApi { @PostMapping("/business-partner") @PostExchange("/business-partner") fun export(): SyncResponse + @Operation( summary = "Fetch information about the latest OpenSearch export", description = "Fetch information about the latest export (either ongoing or already finished)" diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt index fa724f758..1024debca 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt @@ -20,18 +20,18 @@ package org.eclipse.tractusx.bpdm.pool.api - import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.ImportIdEntry import org.eclipse.tractusx.bpdm.pool.api.model.request.ImportIdFilterRequest -import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ImportIdMappingResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody @@ -41,9 +41,9 @@ import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/saas") +@RequestMapping("/api/saas", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/saas") -interface PoolSaasApi { +interface PoolSaasApi { @Operation( summary = "Import new business partner records from SaaS", @@ -60,7 +60,7 @@ interface PoolSaasApi { ) @PostMapping("/business-partner/sync") @PostExchange("/business-partner/sync") - fun importBusinessPartners() : SyncResponse + fun importBusinessPartners(): SyncResponse @Operation( summary = "Fetch information about the SaaS synchronization", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt index 3d28bb013..b84981fc1 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.pool.api - import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Content @@ -36,15 +35,16 @@ import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerUpdateResponseWrapper import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange import org.springframework.web.service.annotation.PutExchange -@RequestMapping("/api/catena/sites") +@RequestMapping("/api/catena/sites", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/sites") -interface PoolSiteApi { +interface PoolSiteApi { @Operation( @@ -57,7 +57,7 @@ interface PoolSiteApi { ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]), ] ) - @PostMapping("/main-addresses/search") + @PostMapping("/main-addresses/search", produces = ["application/json"]) @PostExchange("/main-addresses/search") fun searchMainAddresses( @RequestBody @@ -115,7 +115,7 @@ interface PoolSiteApi { fun createSite( @RequestBody requests: Collection - ) : SitePartnerCreateResponseWrapper + ): SitePartnerCreateResponseWrapper @Operation( summary = "Update existing site business partners", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt index b8f448836..c31736fb1 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt @@ -29,6 +29,7 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSea import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse import org.springdoc.core.annotations.ParameterObject +import org.springframework.http.MediaType import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam @@ -36,7 +37,7 @@ import org.springframework.web.service.annotation.GetExchange import org.springframework.web.service.annotation.HttpExchange -@RequestMapping("/api/catena/suggestions") +@RequestMapping("/api/catena/suggestions", produces = [MediaType.APPLICATION_JSON_VALUE]) @HttpExchange("/api/catena/suggestions") interface PoolSuggestionApi { @Operation( @@ -123,6 +124,7 @@ interface PoolSuggestionApi { @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, @ParameterObject pageRequest: PaginationRequest ): PageResponse + @Operation( summary = "Find best matches for given text in administrative areas", description = "Performs search on administrative area names in order to find the best matches for the given text. " + From dfd330314781a9e37a89582bc39fa4e3f7cc8115 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Wed, 10 May 2023 13:59:44 +0200 Subject: [PATCH 2/5] feat(api): add 'is' to mainAddress and legalAddress response --- .../dto/response/LogisticAddressResponse.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt index eec46f011..497ac49d4 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response +import com.fasterxml.jackson.annotation.JsonProperty import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema import java.time.Instant @@ -27,10 +28,14 @@ import java.time.Instant @Schema(name = "LogisticAddressResponse", description = "Logistic address ") data class LogisticAddressResponse( @Schema(description = "Business Partner Number of this address") + @JsonProperty("bpn") val bpn: String, - @Schema(description = "Name of the logistic address of the business partner. This is not according to official\n" + - "registers but according to the name the uploading sharing member chooses.") + @Schema( + description = "Name of the logistic address of the business partner. This is not according to official\n" + + "registers but according to the name the uploading sharing member chooses." + ) + @JsonProperty("name") val name: String? = null, @ArraySchema(arraySchema = Schema(description = "Address status")) @@ -46,20 +51,26 @@ data class LogisticAddressResponse( val alternativePostalAddress: AlternativePostalAddressResponse? = null, @Schema(description = "BPN of the related legal entity, if available") + @JsonProperty("bpnLegalEntity") val bpnLegalEntity: String?, @Schema(description = "Flag if this is the legal address of its related legal entity") + @get:JsonProperty("isLegalAddress") val isLegalAddress: Boolean = false, @Schema(description = "BPN of the related site, if available") + @JsonProperty("bpnSite") val bpnSite: String?, @Schema(description = "Flag if this is the main address of its related site") + @get:JsonProperty("isMainAddress") val isMainAddress: Boolean = false, @Schema(description = "The timestamp the business partner data was created") + @JsonProperty("createdAt") val createdAt: Instant, @Schema(description = "The timestamp the business partner data was last updated") + @JsonProperty("updatedAt") val updatedAt: Instant ) \ No newline at end of file From af0192f10c71b5f4d465ec86376a9ff886574fcd Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 11 May 2023 07:37:07 +0200 Subject: [PATCH 3/5] feat(api): use @get:Schema to show description in swagger for LogisticAddressResponse --- .../dto/response/LogisticAddressResponse.kt | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt index 497ac49d4..a66b79569 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt @@ -27,15 +27,14 @@ import java.time.Instant @Schema(name = "LogisticAddressResponse", description = "Logistic address ") data class LogisticAddressResponse( - @Schema(description = "Business Partner Number of this address") - @JsonProperty("bpn") + + @get:Schema(description = "Business Partner Number of this address") val bpn: String, - @Schema( + @get:Schema( description = "Name of the logistic address of the business partner. This is not according to official\n" + "registers but according to the name the uploading sharing member chooses." ) - @JsonProperty("name") val name: String? = null, @ArraySchema(arraySchema = Schema(description = "Address status")) @@ -50,27 +49,23 @@ data class LogisticAddressResponse( @Schema(description = "Alternative postal address") val alternativePostalAddress: AlternativePostalAddressResponse? = null, - @Schema(description = "BPN of the related legal entity, if available") - @JsonProperty("bpnLegalEntity") + @get:Schema(description = "BPN of the related legal entity, if available") val bpnLegalEntity: String?, - @Schema(description = "Flag if this is the legal address of its related legal entity") + @get:Schema(description = "Flag if this is the legal address of its related legal entity") @get:JsonProperty("isLegalAddress") val isLegalAddress: Boolean = false, - @Schema(description = "BPN of the related site, if available") - @JsonProperty("bpnSite") + @get:Schema(description = "BPN of the related site, if available") val bpnSite: String?, - @Schema(description = "Flag if this is the main address of its related site") + @get:Schema(description = "Flag if this is the main address of its related site") @get:JsonProperty("isMainAddress") val isMainAddress: Boolean = false, - @Schema(description = "The timestamp the business partner data was created") - @JsonProperty("createdAt") + @get:Schema(description = "The timestamp the business partner data was created") val createdAt: Instant, - @Schema(description = "The timestamp the business partner data was last updated") - @JsonProperty("updatedAt") + @get:Schema(description = "The timestamp the business partner data was last updated") val updatedAt: Instant ) \ No newline at end of file From 2c395a11b7f1c3e79dcee2284bd8dcc1568dbcad Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 11 May 2023 07:49:08 +0200 Subject: [PATCH 4/5] feat(api): add empty scope definition to OAuthFlow because it is required --- .../eclipse/tractusx/bpdm/common/config/OpenApiConfig.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/OpenApiConfig.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/OpenApiConfig.kt index 8afe60262..d5fb7ca88 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/OpenApiConfig.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/OpenApiConfig.kt @@ -22,10 +22,7 @@ package org.eclipse.tractusx.bpdm.common.config import io.swagger.v3.oas.models.Components import io.swagger.v3.oas.models.OpenAPI import io.swagger.v3.oas.models.info.Info -import io.swagger.v3.oas.models.security.OAuthFlow -import io.swagger.v3.oas.models.security.OAuthFlows -import io.swagger.v3.oas.models.security.SecurityRequirement -import io.swagger.v3.oas.models.security.SecurityScheme +import io.swagger.v3.oas.models.security.* import mu.KotlinLogging import org.springdoc.core.customizers.OpenApiCustomizer import org.springdoc.core.models.GroupedOpenApi @@ -73,6 +70,7 @@ class OpenApiConfig( OAuthFlow().authorizationUrl(securityProperties.authUrl) .tokenUrl(securityProperties.tokenUrl) .refreshUrl(securityProperties.refreshUrl) + .scopes(Scopes()) ) ) ) From 39494484ff645f33f223c6500f8618dda3715c2c Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 11 May 2023 13:13:05 +0200 Subject: [PATCH 5/5] feat(api): use Schema(name insteadof @get:JsonProperty --- .../bpdm/common/dto/response/LogisticAddressResponse.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt index a66b79569..2f8949715 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.common.dto.response -import com.fasterxml.jackson.annotation.JsonProperty import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema import java.time.Instant @@ -52,15 +51,13 @@ data class LogisticAddressResponse( @get:Schema(description = "BPN of the related legal entity, if available") val bpnLegalEntity: String?, - @get:Schema(description = "Flag if this is the legal address of its related legal entity") - @get:JsonProperty("isLegalAddress") + @get:Schema(name = "isLegalAddress", description = "Flag if this is the legal address of its related legal entity") val isLegalAddress: Boolean = false, @get:Schema(description = "BPN of the related site, if available") val bpnSite: String?, - @get:Schema(description = "Flag if this is the main address of its related site") - @get:JsonProperty("isMainAddress") + @get:Schema(name = "isMainAddress", description = "Flag if this is the main address of its related site") val isMainAddress: Boolean = false, @get:Schema(description = "The timestamp the business partner data was created")