From 5b18681e964fb24a58b0af48137bc21898929140 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 17 Apr 2024 08:27:08 +0200 Subject: [PATCH] revert-upgrade-openapiprocessor-spring-back-to-2022-5 and fix bookingItem.validFrom assertion (#45) Co-authored-by: Michael Hoennig Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/45 Reviewed-by: Timotheus Pokorra --- build.gradle | 12 ++++++---- .../api-definition/test/test-customers.yaml | 24 +++++++++---------- .../test/test-package-schemas.yaml | 2 +- .../test/test-packages-uuid.yaml | 12 +++++----- .../api-definition/test/test-packages.yaml | 10 ++++---- ...HsBookingItemControllerAcceptanceTest.java | 2 +- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index 254949e5..45b75734 100644 --- a/build.gradle +++ b/build.gradle @@ -115,7 +115,7 @@ tasks.named('test') { openapiProcessor { springRoot { processorName 'spring' - processor 'io.openapiprocessor:openapi-processor-spring:2024.2' + processor 'io.openapiprocessor:openapi-processor-spring:2022.5' apiPath "$projectDir/src/main/resources/api-definition.yaml" mapping "$projectDir/src/main/resources/api-mappings.yaml" targetDir "$buildDir/generated/sources/openapi-javax" @@ -124,7 +124,7 @@ openapiProcessor { } springRbac { processorName 'spring' - processor 'io.openapiprocessor:openapi-processor-spring:2024.2' + processor 'io.openapiprocessor:openapi-processor-spring:2022.5' apiPath "$projectDir/src/main/resources/api-definition/rbac/rbac.yaml" mapping "$projectDir/src/main/resources/api-definition/rbac/api-mappings.yaml" targetDir "$buildDir/generated/sources/openapi-javax" @@ -133,7 +133,7 @@ openapiProcessor { } springTest { processorName 'spring' - processor 'io.openapiprocessor:openapi-processor-spring:2024.2' + processor 'io.openapiprocessor:openapi-processor-spring:2022.5' apiPath "$projectDir/src/main/resources/api-definition/test/test.yaml" mapping "$projectDir/src/main/resources/api-definition/test/api-mappings.yaml" targetDir "$buildDir/generated/sources/openapi-javax" @@ -142,7 +142,7 @@ openapiProcessor { } springHsOffice { processorName 'spring' - processor 'io.openapiprocessor:openapi-processor-spring:2024.2' + processor 'io.openapiprocessor:openapi-processor-spring:2022.5' apiPath "$projectDir/src/main/resources/api-definition/hs-office/hs-office.yaml" mapping "$projectDir/src/main/resources/api-definition/hs-office/api-mappings.yaml" targetDir "$buildDir/generated/sources/openapi-javax" @@ -151,7 +151,7 @@ openapiProcessor { } springHsBooking { processorName 'spring' - processor 'io.openapiprocessor:openapi-processor-spring:2024.2' + processor 'io.openapiprocessor:openapi-processor-spring:2022.5' apiPath "$projectDir/src/main/resources/api-definition/hs-booking/hs-booking.yaml" mapping "$projectDir/src/main/resources/api-definition/hs-booking/api-mappings.yaml" targetDir "$buildDir/generated/sources/openapi-javax" @@ -175,6 +175,8 @@ project.tasks.compileJava.dependsOn processSpring // Rename javax to jakarta in OpenApi generated java files because // io.openapiprocessor.openapi-processor 2022.2 does not yet support the openapiprocessor useSpringBoot3 config option. +// TODO.impl: Upgrade to io.openapiprocessor.openapi-processor >= 2024.2 +// and use either `bean-validation: true` in api-mapping.yaml or `useSpringBoot3 true` (not sure where exactly). task openApiGenerate(type: Copy) { from "$buildDir/generated/sources/openapi-javax" into "$buildDir/generated/sources/openapi" diff --git a/src/main/resources/api-definition/test/test-customers.yaml b/src/main/resources/api-definition/test/test-customers.yaml index 449ed732..89a8fb6b 100644 --- a/src/main/resources/api-definition/test/test-customers.yaml +++ b/src/main/resources/api-definition/test/test-customers.yaml @@ -5,8 +5,8 @@ get: - testCustomers operationId: listCustomers parameters: - - $ref: './auth.yaml#/components/parameters/currentUser' - - $ref: './auth.yaml#/components/parameters/assumedRoles' + - $ref: 'auth.yaml#/components/parameters/currentUser' + - $ref: 'auth.yaml#/components/parameters/assumedRoles' - name: prefix in: query required: false @@ -21,11 +21,11 @@ get: schema: type: array items: - $ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer' + $ref: 'test-customer-schemas.yaml#/components/schemas/TestCustomer' "401": - $ref: './error-responses.yaml#/components/responses/Unauthorized' + $ref: 'error-responses.yaml#/components/responses/Unauthorized' "403": - $ref: './error-responses.yaml#/components/responses/Forbidden' + $ref: 'error-responses.yaml#/components/responses/Forbidden' post: summary: Adds a new customer. @@ -33,13 +33,13 @@ post: - testCustomers operationId: addCustomer parameters: - - $ref: './auth.yaml#/components/parameters/currentUser' - - $ref: './auth.yaml#/components/parameters/assumedRoles' + - $ref: 'auth.yaml#/components/parameters/currentUser' + - $ref: 'auth.yaml#/components/parameters/assumedRoles' requestBody: content: 'application/json': schema: - $ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer' + $ref: 'test-customer-schemas.yaml#/components/schemas/TestCustomer' required: true responses: "201": @@ -47,10 +47,10 @@ post: content: 'application/json': schema: - $ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer' + $ref: 'test-customer-schemas.yaml#/components/schemas/TestCustomer' "401": - $ref: './error-responses.yaml#/components/responses/Unauthorized' + $ref: 'error-responses.yaml#/components/responses/Unauthorized' "403": - $ref: './error-responses.yaml#/components/responses/Forbidden' + $ref: 'error-responses.yaml#/components/responses/Forbidden' "409": - $ref: './error-responses.yaml#/components/responses/Conflict' + $ref: 'error-responses.yaml#/components/responses/Conflict' diff --git a/src/main/resources/api-definition/test/test-package-schemas.yaml b/src/main/resources/api-definition/test/test-package-schemas.yaml index d9e6eb34..dfdeb031 100644 --- a/src/main/resources/api-definition/test/test-package-schemas.yaml +++ b/src/main/resources/api-definition/test/test-package-schemas.yaml @@ -10,7 +10,7 @@ components: type: string format: uuid customer: - $ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer' + $ref: 'test-customer-schemas.yaml#/components/schemas/TestCustomer' name: type: string description: diff --git a/src/main/resources/api-definition/test/test-packages-uuid.yaml b/src/main/resources/api-definition/test/test-packages-uuid.yaml index 6b3b1398..4fc8ef80 100644 --- a/src/main/resources/api-definition/test/test-packages-uuid.yaml +++ b/src/main/resources/api-definition/test/test-packages-uuid.yaml @@ -3,8 +3,8 @@ patch: - testPackages operationId: updatePackage parameters: - - $ref: './auth.yaml#/components/parameters/currentUser' - - $ref: './auth.yaml#/components/parameters/assumedRoles' + - $ref: 'auth.yaml#/components/parameters/currentUser' + - $ref: 'auth.yaml#/components/parameters/assumedRoles' - name: packageUUID in: path required: true @@ -15,15 +15,15 @@ patch: content: 'application/json': schema: - $ref: './test-package-schemas.yaml#/components/schemas/TestPackageUpdate' + $ref: 'test-package-schemas.yaml#/components/schemas/TestPackageUpdate' responses: "200": description: OK content: 'application/json': schema: - $ref: './test-package-schemas.yaml#/components/schemas/TestPackage' + $ref: 'test-package-schemas.yaml#/components/schemas/TestPackage' "401": - $ref: './error-responses.yaml#/components/responses/Unauthorized' + $ref: 'error-responses.yaml#/components/responses/Unauthorized' "403": - $ref: './error-responses.yaml#/components/responses/Forbidden' + $ref: 'error-responses.yaml#/components/responses/Forbidden' diff --git a/src/main/resources/api-definition/test/test-packages.yaml b/src/main/resources/api-definition/test/test-packages.yaml index 53bc128b..6a3e0e7f 100644 --- a/src/main/resources/api-definition/test/test-packages.yaml +++ b/src/main/resources/api-definition/test/test-packages.yaml @@ -3,8 +3,8 @@ get: - testPackages operationId: listPackages parameters: - - $ref: './auth.yaml#/components/parameters/currentUser' - - $ref: './auth.yaml#/components/parameters/assumedRoles' + - $ref: 'auth.yaml#/components/parameters/currentUser' + - $ref: 'auth.yaml#/components/parameters/assumedRoles' - name: name in: query required: false @@ -18,8 +18,8 @@ get: schema: type: array items: - $ref: './test-package-schemas.yaml#/components/schemas/TestPackage' + $ref: 'test-package-schemas.yaml#/components/schemas/TestPackage' "401": - $ref: './error-responses.yaml#/components/responses/Unauthorized' + $ref: 'error-responses.yaml#/components/responses/Unauthorized' "403": - $ref: './error-responses.yaml#/components/responses/Forbidden' + $ref: 'error-responses.yaml#/components/responses/Forbidden' diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index cbd56570..61e533b4 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -273,7 +273,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup assertThat(bookingItemRepo.findByUuid(givenBookingItem.getUuid())).isPresent().get() .matches(mandate -> { assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: rel(anchor='LP First GmbH', type='DEBITOR', holder='LP First GmbH'), fir)"); - assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05"); + assertThat(mandate.getValidFrom()).isEqualTo("2022-11-01"); assertThat(mandate.getValidTo()).isEqualTo("2022-12-31"); return true; });