From f389b60be12f25388c2ddf567740276483970c29 Mon Sep 17 00:00:00 2001 From: Noah Overcash Date: Thu, 3 Oct 2024 15:16:53 -0400 Subject: [PATCH 1/5] [MODLISTS-129] Use migration DTOs from shared repo --- pom.xml | 14 ++---- .../folio/fqm/migration/warnings/Warning.java | 4 ++ .../fqm/resource/MigrationController.java | 16 +++---- .../swagger.api/mod-fqm-manager.yaml | 12 ++--- .../schemas/FqmMigrateRequest.json | 27 ----------- .../schemas/FqmMigrateResponse.json | 46 ------------------- .../controller/MigrationControllerTest.java | 2 +- 7 files changed, 22 insertions(+), 99 deletions(-) delete mode 100644 src/main/resources/swagger.api/schemas/FqmMigrateRequest.json delete mode 100644 src/main/resources/swagger.api/schemas/FqmMigrateResponse.json diff --git a/pom.xml b/pom.xml index 67b76d8d..db724208 100644 --- a/pom.xml +++ b/pom.xml @@ -324,6 +324,10 @@ ApiUtil.java true true + + FqmMigrateRequest=org.folio.querytool.domain.dto.FqmMigrateRequest + FqmMigrateResponse=org.folio.querytool.domain.dto.FqmMigrateResponse + true java @@ -333,16 +337,6 @@ - - - generate - - - ${mod-fqm-manager.yaml.file} - ${project.build.directory}/docs/mod-fqm-manager - html2 - - diff --git a/src/main/java/org/folio/fqm/migration/warnings/Warning.java b/src/main/java/org/folio/fqm/migration/warnings/Warning.java index 7a0d988d..4ac08f9a 100644 --- a/src/main/java/org/folio/fqm/migration/warnings/Warning.java +++ b/src/main/java/org/folio/fqm/migration/warnings/Warning.java @@ -1,12 +1,16 @@ package org.folio.fqm.migration.warnings; +import jakarta.validation.constraints.NotNull; import javax.annotation.CheckForNull; import lombok.RequiredArgsConstructor; import org.folio.fqm.service.LocalizationService; import org.folio.spring.i18n.service.TranslationService; public interface Warning { + @NotNull WarningType getType(); + + @NotNull String getDescription(TranslationService translationService); public static String getDescriptionByAlternativeAndFql( diff --git a/src/main/java/org/folio/fqm/resource/MigrationController.java b/src/main/java/org/folio/fqm/resource/MigrationController.java index ed89bc1e..af3b03d7 100644 --- a/src/main/java/org/folio/fqm/resource/MigrationController.java +++ b/src/main/java/org/folio/fqm/resource/MigrationController.java @@ -1,11 +1,13 @@ package org.folio.fqm.resource; import lombok.RequiredArgsConstructor; -import org.folio.fqm.domain.dto.FqmMigrateRequest; -import org.folio.fqm.domain.dto.FqmMigrateResponse; -import org.folio.fqm.domain.dto.FqmMigrateResponseWarningsInner; + +import org.apache.commons.lang3.StringUtils; import org.folio.fqm.migration.MigratableQueryInformation; import org.folio.fqm.service.MigrationService; +import org.folio.querytool.domain.dto.FqmMigrateRequest; +import org.folio.querytool.domain.dto.FqmMigrateResponse; +import org.folio.querytool.domain.dto.FqmMigrateWarning; import org.folio.spring.i18n.service.TranslationService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -39,11 +41,9 @@ public ResponseEntity fqmMigrate(FqmMigrateRequest fqmMigrat .fqlQuery(updatedQueryInfo.fqlQuery()) .fields(updatedQueryInfo.fields()) .warnings(updatedQueryInfo.warnings().stream() - .map(warning -> new FqmMigrateResponseWarningsInner() - .type(warning.getType() != null ? warning.getType().toString() : null) - .description(warning.getDescription(translationService) != null ? - warning.getDescription(translationService) : "No description provided" - ) + .map(warning -> new FqmMigrateWarning() + .type(warning.getType().toString()) + .description(warning.getDescription(translationService)) ) .toList() ); diff --git a/src/main/resources/swagger.api/mod-fqm-manager.yaml b/src/main/resources/swagger.api/mod-fqm-manager.yaml index ba023a70..2e639707 100644 --- a/src/main/resources/swagger.api/mod-fqm-manager.yaml +++ b/src/main/resources/swagger.api/mod-fqm-manager.yaml @@ -91,14 +91,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/fqmMigrateRequest' + description: Mapped to schemas in folio-query-tool-metadata + type: FqmMigrateRequest responses: '200': - description: 'FQM version updated successfully' + description: 'FQM version updated successfully' content: application/json: schema: - $ref: '#/components/schemas/fqmMigrateResponse' + description: Mapped to schemas in folio-query-tool-metadata + type: FqmMigrateResponse '400': $ref: '#/components/responses/badRequestResponse' '500': @@ -157,10 +159,6 @@ components: type: array items: type: string - fqmMigrateRequest: - $ref: schemas/FqmMigrateRequest.json - fqmMigrateResponse: - $ref: schemas/FqmMigrateResponse.json responses: badRequestResponse: diff --git a/src/main/resources/swagger.api/schemas/FqmMigrateRequest.json b/src/main/resources/swagger.api/schemas/FqmMigrateRequest.json deleted file mode 100644 index ac532bf1..00000000 --- a/src/main/resources/swagger.api/schemas/FqmMigrateRequest.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Entity Upgrade Request", - "description": "Schema for a request to upgrade an entity payload, including an entity type ID, FQL query, and list of fields.", - "type": "object", - "properties": { - "entityTypeId": { - "description": "ID of the entity type to be upgraded", - "type": "string", - "format": "UUID" - }, - "fqlQuery": { - "description": "FQL query string to be used for the upgrade", - "type": "string" - }, - "fields": { - "description": "List of fields to be included in the upgrade", - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "entityTypeId" - ] -} diff --git a/src/main/resources/swagger.api/schemas/FqmMigrateResponse.json b/src/main/resources/swagger.api/schemas/FqmMigrateResponse.json deleted file mode 100644 index 062f7186..00000000 --- a/src/main/resources/swagger.api/schemas/FqmMigrateResponse.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Entity Upgrade Response", - "description": "Schema for a response to upgrade FQM", - "type": "object", - "properties": { - "entityTypeId": { - "description": "ID of the entity type upgraded successfully", - "type": "string", - "format": "UUID" - }, - "fqlQuery": { - "description": "FQL query string upgraded successfully", - "type": "string" - }, - "fields": { - "description": "List of fields upgraded successfully", - "type": "array", - "items": { - "type": "string" - } - }, - "warnings": { - "description": "List of warnings issued during the upgrade", - "type": "array", - "items": { - "type": "object", - "properties": { - "description": { - "description": "Description of the warning", - "type": "string" - }, - "type": { - "description": "Type of warning", - "type": "string" - } - }, - "required": [ - ] - } - } -}, - "required": [ - "entityTypeId" - ] -} diff --git a/src/test/java/org/folio/fqm/controller/MigrationControllerTest.java b/src/test/java/org/folio/fqm/controller/MigrationControllerTest.java index c3d0edf0..20fcea41 100644 --- a/src/test/java/org/folio/fqm/controller/MigrationControllerTest.java +++ b/src/test/java/org/folio/fqm/controller/MigrationControllerTest.java @@ -1,12 +1,12 @@ package org.folio.fqm.controller; import com.fasterxml.jackson.databind.ObjectMapper; -import org.folio.fqm.domain.dto.FqmMigrateRequest; import org.folio.fqm.migration.MigratableQueryInformation; import org.folio.fqm.migration.warnings.DeprecatedEntityWarning; import org.folio.fqm.migration.warnings.Warning; import org.folio.fqm.resource.MigrationController; import org.folio.fqm.service.MigrationService; +import org.folio.querytool.domain.dto.FqmMigrateRequest; import org.folio.spring.FolioExecutionContext; import org.folio.spring.i18n.service.TranslationService; import org.folio.spring.integration.XOkapiHeaders; From ba265a34f8e3e8afe919c4599beae6fcc5b882bb Mon Sep 17 00:00:00 2001 From: Noah Overcash Date: Fri, 4 Oct 2024 10:48:17 -0400 Subject: [PATCH 2/5] Use openapi transformation agreeable to api-lint --- pom.xml | 14 +++++++++----- .../folio/fqm/resource/MigrationController.java | 2 -- .../resources/swagger.api/mod-fqm-manager.yaml | 8 +++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index db724208..79322474 100644 --- a/pom.xml +++ b/pom.xml @@ -302,7 +302,7 @@ org.openapitools openapi-generator-maven-plugin - ${openapi-generator.version} + 7.8.0 mod-fqm-manager-openapi @@ -324,10 +324,14 @@ ApiUtil.java true true - - FqmMigrateRequest=org.folio.querytool.domain.dto.FqmMigrateRequest - FqmMigrateResponse=org.folio.querytool.domain.dto.FqmMigrateResponse - + + object+FqmMigrateRequest=FqmMigrateRequest + object+FqmMigrateResponse=FqmMigrateResponse + + + FqmMigrateRequest=org.folio.querytool.domain.dto.FqmMigrateRequest + FqmMigrateResponse=org.folio.querytool.domain.dto.FqmMigrateResponse + true java diff --git a/src/main/java/org/folio/fqm/resource/MigrationController.java b/src/main/java/org/folio/fqm/resource/MigrationController.java index af3b03d7..b0bcab83 100644 --- a/src/main/java/org/folio/fqm/resource/MigrationController.java +++ b/src/main/java/org/folio/fqm/resource/MigrationController.java @@ -2,7 +2,6 @@ import lombok.RequiredArgsConstructor; -import org.apache.commons.lang3.StringUtils; import org.folio.fqm.migration.MigratableQueryInformation; import org.folio.fqm.service.MigrationService; import org.folio.querytool.domain.dto.FqmMigrateRequest; @@ -13,7 +12,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; - @RestController @RequiredArgsConstructor public class MigrationController implements FqmVersionApi { diff --git a/src/main/resources/swagger.api/mod-fqm-manager.yaml b/src/main/resources/swagger.api/mod-fqm-manager.yaml index 2e639707..b6f1be11 100644 --- a/src/main/resources/swagger.api/mod-fqm-manager.yaml +++ b/src/main/resources/swagger.api/mod-fqm-manager.yaml @@ -91,8 +91,9 @@ paths: content: application/json: schema: - description: Mapped to schemas in folio-query-tool-metadata - type: FqmMigrateRequest + description: Mapped to schema in folio-query-tool-metadata + type: object + format: FqmMigrateRequest responses: '200': description: 'FQM version updated successfully' @@ -100,7 +101,8 @@ paths: application/json: schema: description: Mapped to schemas in folio-query-tool-metadata - type: FqmMigrateResponse + type: object + format: FqmMigrateResponse '400': $ref: '#/components/responses/badRequestResponse' '500': From 7ba9ac979ea877ac99ee80087c4e533d0bed6ef8 Mon Sep 17 00:00:00 2001 From: Noah Overcash Date: Fri, 4 Oct 2024 10:51:21 -0400 Subject: [PATCH 3/5] fix version testing --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 79322474..344e3a4c 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 4.11.0 - 6.2.1 + 7.8.0 1.0.1 3.0.0-M7 1.18.30 @@ -302,7 +302,7 @@ org.openapitools openapi-generator-maven-plugin - 7.8.0 + ${openapi-generator.version} mod-fqm-manager-openapi From 80c41eeacfdaf7ca52902e1604d8c7852864a9c3 Mon Sep 17 00:00:00 2001 From: Noah Overcash Date: Fri, 4 Oct 2024 10:58:43 -0400 Subject: [PATCH 4/5] idk why this happened --- .../org/folio/fqm/controller/EntityTypeControllerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java b/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java index ef86fc2b..039b6055 100644 --- a/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java +++ b/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java @@ -114,10 +114,10 @@ void shouldGetEntityTypeSummaryForValidIds() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.entityTypes.[0].id", is(expectedSummary.get(0).getId().toString()))) .andExpect(jsonPath("$.entityTypes.[0].label", is(expectedSummary.get(0).getLabel()))) - .andExpect(jsonPath("$.entityTypes.[0].missingPermissions").doesNotExist()) + .andExpect(jsonPath("$.entityTypes.[0].missingPermissions").isEmpty()) .andExpect(jsonPath("$.entityTypes.[1].id", is(expectedSummary.get(1).getId().toString()))) .andExpect(jsonPath("$.entityTypes.[1].label", is(expectedSummary.get(1).getLabel()))) - .andExpect(jsonPath("$.entityTypes.[1].missingPermissions").doesNotExist()) + .andExpect(jsonPath("$.entityTypes.[1].missingPermissions").isEmpty()) .andExpect(jsonPath("$._version", is("newest coolest version"))); verify(entityTypeService, times(1)).getEntityTypeSummary(ids, false); From f6e0138eec5d17e5a2b4bb089e70bf48444551bd Mon Sep 17 00:00:00 2001 From: Noah Overcash Date: Fri, 4 Oct 2024 11:06:12 -0400 Subject: [PATCH 5/5] use openapi-generator 7.4 --- pom.xml | 2 +- .../org/folio/fqm/controller/EntityTypeControllerTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 344e3a4c..5643511a 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 4.11.0 - 7.8.0 + 7.4.0 1.0.1 3.0.0-M7 1.18.30 diff --git a/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java b/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java index 039b6055..ef86fc2b 100644 --- a/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java +++ b/src/test/java/org/folio/fqm/controller/EntityTypeControllerTest.java @@ -114,10 +114,10 @@ void shouldGetEntityTypeSummaryForValidIds() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.entityTypes.[0].id", is(expectedSummary.get(0).getId().toString()))) .andExpect(jsonPath("$.entityTypes.[0].label", is(expectedSummary.get(0).getLabel()))) - .andExpect(jsonPath("$.entityTypes.[0].missingPermissions").isEmpty()) + .andExpect(jsonPath("$.entityTypes.[0].missingPermissions").doesNotExist()) .andExpect(jsonPath("$.entityTypes.[1].id", is(expectedSummary.get(1).getId().toString()))) .andExpect(jsonPath("$.entityTypes.[1].label", is(expectedSummary.get(1).getLabel()))) - .andExpect(jsonPath("$.entityTypes.[1].missingPermissions").isEmpty()) + .andExpect(jsonPath("$.entityTypes.[1].missingPermissions").doesNotExist()) .andExpect(jsonPath("$._version", is("newest coolest version"))); verify(entityTypeService, times(1)).getEntityTypeSummary(ids, false);