From 4c2a70e65628f30173271f545fb929bcef414ec7 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Tue, 29 Aug 2023 10:50:23 +0200 Subject: [PATCH] chore: added swagger docs to stockcontroller endpoints, set edr log level to debug --- DEPENDENCIES_BACKEND | 38 ------------------- .../EndpointDataReferenceReceiver.java | 2 +- .../stock/controller/StockController.java | 27 +++++++++++++ 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/DEPENDENCIES_BACKEND b/DEPENDENCIES_BACKEND index d7ee2ac8..d41e2849 100644 --- a/DEPENDENCIES_BACKEND +++ b/DEPENDENCIES_BACKEND @@ -8,11 +8,8 @@ maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.14.1, maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.14.1, Apache-2.0, approved, #4699 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.14.1, Apache-2.0, approved, #5938 maven/mavencentral/com.fasterxml/classmate/1.5.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.jayway.jsonpath/json-path/2.7.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.squareup.okhttp/okhttp/2.7.5, Apache-2.0, approved, clearlydefined maven/mavencentral/com.squareup.okio/okio/1.6.0, Apache-2.0, approved, CQ11382 -maven/mavencentral/com.sun.istack/istack-commons-runtime/4.1.1, BSD-3-Clause, approved, #2590 -maven/mavencentral/com.vaadin.external.google/android-json/0.0.20131108.vaadin1, Apache-2.0, approved, CQ21310 maven/mavencentral/com.zaxxer/HikariCP/5.0.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.micrometer/micrometer-commons/1.10.3, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #7333 maven/mavencentral/io.micrometer/micrometer-observation/1.10.3, Apache-2.0, approved, #7331 @@ -21,50 +18,22 @@ maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.9, Apache-2.0, ap maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.9, Apache-2.0, approved, #5919 maven/mavencentral/jakarta.activation/jakarta.activation-api/2.1.1, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.ca -maven/mavencentral/jakarta.inject/jakarta.inject-api/2.0.0, Apache-2.0, approved, clearlydefined maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.1.0, EPL-2.0 OR BSD-3-Clause AND (EPL-2.0 OR BSD-3-Clause AND BSD-3-Clause), approved, #7696 maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.1, EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #7697 maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, clearlydefined maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.0, BSD-3-Clause, approved, ee4j.jaxb -maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.12.22, Apache-2.0, approved, #1810 -maven/mavencentral/net.bytebuddy/byte-buddy/1.12.22, Apache-2.0 AND BSD-3-Clause, approved, #1811 -maven/mavencentral/net.minidev/accessors-smart/2.4.8, Apache-2.0, approved, #7515 -maven/mavencentral/net.minidev/json-smart/2.4.8, Apache-2.0, approved, #3288 -maven/mavencentral/org.antlr/antlr4-runtime/4.10.1, BSD-3-Clause AND LicenseRef-Public-domain AND MIT AND LicenseRef-Unicode-TOU, approved, #7065 maven/mavencentral/org.apache.commons/commons-lang3/3.12.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-api/2.19.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-to-slf4j/2.19.0, Apache-2.0, approved, #5941 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.5, Apache-2.0 AND (EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND (CDDL-1.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND W3C AND CC0-1.0, approved, #5949 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-el/10.1.5, Apache-2.0, approved, #6997 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.5, Apache-2.0, approved, #7920 -maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined maven/mavencentral/org.aspectj/aspectjweaver/1.9.19, EPL-1.0, approved, tools.aspectj -maven/mavencentral/org.assertj/assertj-core/3.23.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.eclipse.angus/angus-activation/1.0.0, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.angus -maven/mavencentral/org.glassfish.jaxb/jaxb-core/4.0.1, BSD-3-Clause, approved, ee4j.jaxb -maven/mavencentral/org.glassfish.jaxb/jaxb-runtime/4.0.1, BSD-3-Clause, approved, ee4j.jaxb -maven/mavencentral/org.glassfish.jaxb/txw2/4.0.1, BSD-3-Clause, approved, ee4j.jaxb -maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined -maven/mavencentral/org.hibernate.common/hibernate-commons-annotations/6.0.2.Final, LGPL-2.1-only, approved, #6962 maven/mavencentral/org.hibernate.orm/hibernate-core/6.1.6.Final, LGPL-2.1-or-later AND (Apache-2.0 AND LGPL-2.1-only) AND (CC-PDDC AND LGPL-2.1-only) AND (EPL-2.0 OR BSD-3-Clause), approved, #5939 maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.0.Final, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.hsqldb/hsqldb/2.7.1, BSD-3-Clause, approved, clearlydefined maven/mavencentral/org.jboss.logging/jboss-logging/3.5.0.Final, Apache-2.0, approved, #9471 -maven/mavencentral/org.jboss/jandex/2.4.2.Final, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.9.2, EPL-2.0, approved, #3133 -maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.9.2, EPL-2.0, approved, #3125 -maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.9.2, EPL-2.0, approved, #3134 -maven/mavencentral/org.junit.jupiter/junit-jupiter/5.9.2, EPL-2.0, approved, #6972 -maven/mavencentral/org.junit.platform/junit-platform-commons/1.9.2, EPL-2.0, approved, #3130 -maven/mavencentral/org.junit.platform/junit-platform-engine/1.9.2, EPL-2.0, approved, #3128 -maven/mavencentral/org.mockito/mockito-core/4.8.1, MIT, approved, clearlydefined -maven/mavencentral/org.mockito/mockito-junit-jupiter/4.8.1, MIT, approved, clearlydefined maven/mavencentral/org.modelmapper/modelmapper/3.1.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.objenesis/objenesis/3.2, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.opentest4j/opentest4j/1.2.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.ow2.asm/asm/9.1, BSD-3-Clause, approved, CQ23029 maven/mavencentral/org.projectlombok/lombok/1.18.24, MIT AND LicenseRef-Public-Domain, approved, CQ23907 -maven/mavencentral/org.skyscreamer/jsonassert/1.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.6, MIT, approved, #7698 maven/mavencentral/org.slf4j/slf4j-api/2.0.6, MIT, approved, #5915 maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.1.0, Apache-2.0, approved, clearlydefined @@ -72,26 +41,21 @@ maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.1.0, Apa maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.1.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.0.2, Apache-2.0, approved, #6981 maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.0.2, Apache-2.0, approved, #6973 -maven/mavencentral/org.springframework.boot/spring-boot-devtools/3.0.2, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.0.2, Apache-2.0, approved, #6965 maven/mavencentral/org.springframework.boot/spring-boot-starter-data-jpa/3.0.2, Apache-2.0, approved, #7351 maven/mavencentral/org.springframework.boot/spring-boot-starter-jdbc/3.0.2, Apache-2.0, approved, #6974 maven/mavencentral/org.springframework.boot/spring-boot-starter-json/3.0.2, Apache-2.0, approved, #7006 maven/mavencentral/org.springframework.boot/spring-boot-starter-logging/3.0.2, Apache-2.0, approved, #6982 maven/mavencentral/org.springframework.boot/spring-boot-starter-security/3.0.2, Apache-2.0, approved, #7329 -maven/mavencentral/org.springframework.boot/spring-boot-starter-test/3.0.2, Apache-2.0, approved, #7001 maven/mavencentral/org.springframework.boot/spring-boot-starter-tomcat/3.0.2, Apache-2.0, approved, #6987 maven/mavencentral/org.springframework.boot/spring-boot-starter-web/3.0.2, Apache-2.0, approved, #5945 maven/mavencentral/org.springframework.boot/spring-boot-starter/3.0.2, Apache-2.0, approved, #7330 -maven/mavencentral/org.springframework.boot/spring-boot-test-autoconfigure/3.0.2, Apache-2.0, approved, #6966 -maven/mavencentral/org.springframework.boot/spring-boot-test/3.0.2, Apache-2.0, approved, #6976 maven/mavencentral/org.springframework.boot/spring-boot/3.0.2, Apache-2.0, approved, #7327 maven/mavencentral/org.springframework.data/spring-data-commons/3.0.1, Apache-2.0, approved, #5943 maven/mavencentral/org.springframework.data/spring-data-jpa/3.0.1, Apache-2.0, approved, #5935 maven/mavencentral/org.springframework.security/spring-security-config/6.0.1, Apache-2.0, approved, #7338 maven/mavencentral/org.springframework.security/spring-security-core/6.0.1, Apache-2.0, approved, #7325 maven/mavencentral/org.springframework.security/spring-security-crypto/6.0.1, Apache-2.0 AND ISC, approved, #7326 -maven/mavencentral/org.springframework.security/spring-security-test/6.0.1, Apache-2.0, approved, #7402 maven/mavencentral/org.springframework.security/spring-security-web/6.0.1, Apache-2.0, approved, #7328 maven/mavencentral/org.springframework.session/spring-session-core/3.0.0, Apache-2.0, approved, #7858 maven/mavencentral/org.springframework/spring-aop/6.0.4, Apache-2.0, approved, #5940 @@ -103,10 +67,8 @@ maven/mavencentral/org.springframework/spring-expression/6.0.4, Apache-2.0, appr maven/mavencentral/org.springframework/spring-jcl/6.0.4, Apache-2.0, approved, #3283 maven/mavencentral/org.springframework/spring-jdbc/6.0.4, Apache-2.0, approved, #5924 maven/mavencentral/org.springframework/spring-orm/6.0.4, Apache-2.0, approved, #5925 -maven/mavencentral/org.springframework/spring-test/6.0.4, Apache-2.0, approved, #7003 maven/mavencentral/org.springframework/spring-tx/6.0.4, Apache-2.0, approved, #5926 maven/mavencentral/org.springframework/spring-web/6.0.4, Apache-2.0, approved, #5942 maven/mavencentral/org.springframework/spring-webmvc/6.0.4, Apache-2.0, approved, #5944 maven/mavencentral/org.webjars/swagger-ui/4.18.2, Apache-2.0, approved, #7850 -maven/mavencentral/org.xmlunit/xmlunit-core/2.9.1, Apache-2.0, approved, #6272 maven/mavencentral/org.yaml/snakeyaml/1.33, Apache-2.0, approved, clearlydefined diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java index 82c0ed40..7f928aca 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java @@ -76,7 +76,7 @@ public class EndpointDataReferenceReceiver { @ApiResponse(responseCode = "400", description = "Received invalid message") }) private ResponseEntity authCodeReceivingEndpoint(@RequestBody JsonNode body) { - log.info("Received edr data:\n" + body.toPrettyString()); + log.debug("Received edr data:\n" + body.toPrettyString()); String transferId = body.get("id").asText(); String authKey = body.get("authKey").asText(); String authCode = body.get("authCode").asText(); diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockController.java index 92eb8110..2e21c175 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockController.java @@ -23,6 +23,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.squareup.okhttp.Response; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.puris.backend.common.api.domain.model.MessageHeader; import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum; @@ -112,6 +117,7 @@ public class StockController { @CrossOrigin @GetMapping("materials") @ResponseBody + @Operation(description = "Returns a list of all materials (excluding products)") public List getMaterials() { return materialService.findAllMaterials() .stream() @@ -122,6 +128,13 @@ public List getMaterials() { @CrossOrigin @GetMapping("materialnumbers-mapping") @ResponseBody + @Operation(description = "Returns a mapping of all material numbers, that others partners are using" + + "for the material given in the request parameter.") + @ApiResponses(value = {@ApiResponse(content = @Content(examples = { + @ExampleObject(name = "Basic sample", value = "{" + + " \"BPNL1234567890ZZ\": \"MNR-8101-ID146955.001\"," + + " \"BPNL4444444444XX\": \"MNR-7307-AU340474.002\"}") + }))}) public Map getMaterialNumbers(@RequestParam String ownMaterialNumber) { return mprService.getBPNL_To_MaterialNumberMap(ownMaterialNumber); } @@ -129,6 +142,7 @@ public Map getMaterialNumbers(@RequestParam String ownMaterialNu @CrossOrigin @GetMapping("products") @ResponseBody + @Operation(description = "Returns a list of all products (excluding materials)") public List getProducts() { return materialService.findAllProducts() .stream() @@ -139,6 +153,7 @@ public List getProducts() { @CrossOrigin @GetMapping("product-stocks") @ResponseBody + @Operation(description = "Returns a list of all product-stocks") public List getProductStocks() { List allProductStocks = productStockService.findAll().stream() .map(this::convertToDto) @@ -150,6 +165,7 @@ public List getProductStocks() { @CrossOrigin @PostMapping("product-stocks") @ResponseBody + @Operation(description = "Creates a new product-stock") public ProductStockDto createProductStocks(@RequestBody ProductStockDto productStockDto) { ProductStock productStockToCreate = convertToEntity(productStockDto); @@ -170,6 +186,7 @@ public ProductStockDto createProductStocks(@RequestBody ProductStockDto productS @CrossOrigin @PutMapping("product-stocks") @ResponseBody + @Operation(description = "Updates an existing product-stock") public ProductStockDto updateProductStocks(@RequestBody ProductStockDto productStockDto) { ProductStock existingProductStock = productStockService.findByUuid(productStockDto.getUuid()); if (existingProductStock.getUuid() == null) { @@ -206,6 +223,7 @@ private ProductStock convertToEntity(ProductStockDto dto) { @CrossOrigin @GetMapping("material-stocks") @ResponseBody + @Operation(description = "Returns a list of all material-stocks") public List getMaterialStocks() { List allMaterialStocks = materialStockService.findAll().stream() .map(this::convertToDto) @@ -217,6 +235,7 @@ public List getMaterialStocks() { @CrossOrigin @PostMapping("material-stocks") @ResponseBody + @Operation(description = "Creates a new material-stock") public MaterialStockDto createMaterialStocks(@RequestBody MaterialStockDto materialStockDto) { MaterialStock materialStockToCreate = convertToEntity(materialStockDto); @@ -232,6 +251,7 @@ public MaterialStockDto createMaterialStocks(@RequestBody MaterialStockDto mater @CrossOrigin @PutMapping("material-stocks") @ResponseBody + @Operation(description = "Updates an existing material-stock") public MaterialStockDto updateMaterialStocks(@RequestBody MaterialStockDto materialStockDto) { MaterialStock existingMaterialStock = materialStockService.findByUuid(materialStockDto.getUuid()); if (existingMaterialStock == null || existingMaterialStock.getUuid() == null) { @@ -265,6 +285,7 @@ private MaterialStock convertToEntity(MaterialStockDto dto) { @CrossOrigin @GetMapping("partner-product-stocks") @ResponseBody + @Operation(description = "Returns a list of all partner-product-stocks that refer to the given material number") public List getPartnerProductStocks(@RequestParam String ownMaterialNumber) { return partnerProductStockService. findAllByOwnMaterialNumber(ownMaterialNumber) @@ -287,6 +308,7 @@ private PartnerProductStockDto convertToDto(PartnerProductStock entity) { @CrossOrigin @GetMapping("customer") @ResponseBody + @Operation(description = "Returns a list of all Partners that are ordering the given material") public List getCustomerPartnersOrderingMaterial(@RequestParam String ownMaterialNumber) { List allCustomerPartners = partnerService.findAllCustomerPartnersForMaterialId(ownMaterialNumber).stream() .map(this::convertToDto) @@ -297,6 +319,11 @@ public List getCustomerPartnersOrderingMaterial(@RequestParam String @CrossOrigin @GetMapping("update-partner-product-stock") @ResponseBody + @Operation(description = "For the given material, all known suppliers will be requested to report their" + + "current product-stocks. The response body contains a list of those supplier partners that were sent a request." + + "Please note that these requests are handled asynchronously by the partners, so there are no guarantees, if and " + + "when the corresponding responses will be available. As soon as a response arrives, it will be available via a " + + "call to the GET partner-product-stocks endpoint.") public List triggerPartnerProductStockUpdateForMaterial(@RequestParam String ownMaterialNumber) { Material materialEntity = materialService.findByOwnMaterialNumber(ownMaterialNumber);