Skip to content

Commit

Permalink
[MODLISTS-129] Use migration DTOs from shared repo (#445)
Browse files Browse the repository at this point in the history
* [MODLISTS-129] Use migration DTOs from shared repo

* Use openapi transformation agreeable to api-lint

* fix version testing

* idk why this happened

* use openapi-generator 7.4
  • Loading branch information
ncovercash authored Oct 4, 2024
1 parent ada0c6b commit cb3d49f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 101 deletions.
20 changes: 9 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<mockwebserver.version>4.11.0</mockwebserver.version>

<!-- plugins -->
<openapi-generator.version>6.2.1</openapi-generator.version>
<openapi-generator.version>7.4.0</openapi-generator.version>
<copy-rename-maven-plugin.version>1.0.1</copy-rename-maven-plugin.version>
<maven-release-plugin.version>3.0.0-M7</maven-release-plugin.version>
<lombok.version>1.18.30</lombok.version>
Expand Down Expand Up @@ -324,6 +324,14 @@
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<generateModelDocumentation>true</generateModelDocumentation>
<skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
<typeMappings>
<typeMapping>object+FqmMigrateRequest=FqmMigrateRequest</typeMapping>
<typeMapping>object+FqmMigrateResponse=FqmMigrateResponse</typeMapping>
</typeMappings>
<importMappings>
<importMapping>FqmMigrateRequest=org.folio.querytool.domain.dto.FqmMigrateRequest</importMapping>
<importMapping>FqmMigrateResponse=org.folio.querytool.domain.dto.FqmMigrateResponse</importMapping>
</importMappings>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
Expand All @@ -333,16 +341,6 @@
</configOptions>
</configuration>
</execution>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${mod-fqm-manager.yaml.file}</inputSpec>
<output>${project.build.directory}/docs/mod-fqm-manager</output>
<generatorName>html2</generatorName>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/folio/fqm/migration/warnings/Warning.java
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/org/folio/fqm/resource/MigrationController.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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.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;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequiredArgsConstructor
public class MigrationController implements FqmVersionApi {
Expand Down Expand Up @@ -39,11 +39,9 @@ public ResponseEntity<FqmMigrateResponse> 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()
);
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/swagger.api/mod-fqm-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/fqmMigrateRequest'
description: Mapped to schema in folio-query-tool-metadata
type: object
format: 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: object
format: FqmMigrateResponse
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
Expand Down Expand Up @@ -157,10 +161,6 @@ components:
type: array
items:
type: string
fqmMigrateRequest:
$ref: schemas/FqmMigrateRequest.json
fqmMigrateResponse:
$ref: schemas/FqmMigrateResponse.json

responses:
badRequestResponse:
Expand Down
27 changes: 0 additions & 27 deletions src/main/resources/swagger.api/schemas/FqmMigrateRequest.json

This file was deleted.

46 changes: 0 additions & 46 deletions src/main/resources/swagger.api/schemas/FqmMigrateResponse.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit cb3d49f

Please sign in to comment.