From 7d5af562acdaf1d49be71ac02c6338c9ef4d9db2 Mon Sep 17 00:00:00 2001 From: ndc-dxc Date: Thu, 3 Oct 2024 16:34:18 +0200 Subject: [PATCH 1/2] harvester will stop for fatal errors --- .../BaseSemanticAssetHarvester.java | 28 ++++++++++++++++++- .../ndc/repository/TripleStoreRepository.java | 12 ++++++-- .../ndc/service/DefaultInstanceManager.java | 10 +++++++ .../resources/application-local.properties | 2 +- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/gov/innovazione/ndc/harvester/harvesters/BaseSemanticAssetHarvester.java b/src/main/java/it/gov/innovazione/ndc/harvester/harvesters/BaseSemanticAssetHarvester.java index dd19e9e..bb7b851 100644 --- a/src/main/java/it/gov/innovazione/ndc/harvester/harvesters/BaseSemanticAssetHarvester.java +++ b/src/main/java/it/gov/innovazione/ndc/harvester/harvesters/BaseSemanticAssetHarvester.java @@ -21,16 +21,21 @@ import java.io.File; import java.nio.file.Path; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import static it.gov.innovazione.ndc.harvester.service.ActualConfigService.ConfigKey.MAX_FILE_SIZE_BYTES; @Slf4j @RequiredArgsConstructor public abstract class BaseSemanticAssetHarvester

implements SemanticAssetHarvester { + + private static final List INFRASTRUCTURE_EXCEPTIONS = List.of("java.net", "org.apache.http"); + private final SemanticAssetType type; private final NdcEventPublisher eventPublisher; private final ConfigService configService; @@ -40,6 +45,10 @@ public SemanticAssetType getType() { return type; } + private static boolean isInfrastructureTypeException(Throwable cause) { + return INFRASTRUCTURE_EXCEPTIONS.stream().anyMatch(cause.getClass().getName()::contains); + } + @Override public void harvest(Repository repository, Path rootPath) { log.debug("Looking for {} paths", type); @@ -58,6 +67,7 @@ public void harvest(Repository repository, Path rootPath) { processPath(repository.getUrl(), path); log.debug("Path {} processed correctly for {}", path, type); } catch (SinglePathProcessingException e) { + boolean isInfrastuctureError = checkInfrastructureError(e); Optional.ofNullable(HarvestExecutionContextUtils.getContext()) .ifPresent(context -> context.addHarvestingError(repository, e, path.getAllFiles())); eventPublisher.publishAlertableEvent( @@ -65,7 +75,7 @@ public void harvest(Repository repository, Path rootPath) { DefaultAlertableEvent.builder() .name("Harvester Single Path Processing Error") .description("Error processing " + type + " " + path + " in repo " + repository.getUrl()) - .category(EventCategory.SEMANTIC) + .category(isInfrastuctureError ? EventCategory.INFRASTRUCTURE : EventCategory.SEMANTIC) .severity(Severity.ERROR) .context(Map.of( "error", e.getRealErrorMessage(), @@ -81,6 +91,22 @@ public void harvest(Repository repository, Path rootPath) { } } + private boolean checkInfrastructureError(SinglePathProcessingException e) { + // checks if in the chain of exceptions there is an infrastructure error (es. java.net, httpException, etc) + Throwable cause = e; + Set seen = new HashSet<>(); + while (cause != null) { + if (!seen.add(cause)) { + return false; + } + if (isInfrastructureTypeException(cause)) { + return true; + } + cause = cause.getCause(); + } + return false; + } + private void notifyIfSizeExceed(P path, Long maxFileSizeBytes) { HarvestExecutionContext context = HarvestExecutionContextUtils.getContext(); if (Objects.nonNull(context) && Objects.nonNull(path)) { diff --git a/src/main/java/it/gov/innovazione/ndc/repository/TripleStoreRepository.java b/src/main/java/it/gov/innovazione/ndc/repository/TripleStoreRepository.java index 3e00b49..5a36aca 100644 --- a/src/main/java/it/gov/innovazione/ndc/repository/TripleStoreRepository.java +++ b/src/main/java/it/gov/innovazione/ndc/repository/TripleStoreRepository.java @@ -30,8 +30,13 @@ public TripleStoreRepository(VirtuosoClient virtuosoClient) { this.virtuosoClient = virtuosoClient; } + private static String getCommandAndLog(String command) { + log.info("Update command: {}", command); + return command; + } + private static String getRenameCommand(String oldGraph, String newGraph) { - return format(RENAME_GRAPH, oldGraph, newGraph); + return getCommandAndLog(format(RENAME_GRAPH, oldGraph, newGraph)); } private void saveWithConnection(String graphName, Model model, RDFConnection connection) { @@ -48,7 +53,7 @@ private void saveWithConnection(String graphName, Model model, RDFConnection con } private static String getUpdateCommand(String repoUrl, String repoUrlPrefix) { - return format(DROP_SILENT_GRAPH_WITH_LOG_ENABLE_3, reworkRepoUrlIfNecessary(repoUrl, repoUrlPrefix)); + return getCommandAndLog(format(DROP_SILENT_GRAPH_WITH_LOG_ENABLE_3, reworkRepoUrlIfNecessary(repoUrl, repoUrlPrefix))); } @SneakyThrows @@ -62,11 +67,13 @@ private static String reworkRepoUrlIfNecessary(String repoUrl, String repoUrlPre } public void clearExistingNamedGraph(String repoUrl) { + log.info("Clearing existing named graph for {}", repoUrl); clearExistingNamedGraph(repoUrl, ONLINE_GRAPH_PREFIX); } public void clearExistingNamedGraph(String repoUrl, String prefix) { try { + log.info("Clearing existing named graph for {} with prefix {}", repoUrl, prefix); String sparqlEndpoint = virtuosoClient.getSparqlEndpoint(); UpdateExecution .service(sparqlEndpoint) @@ -92,6 +99,7 @@ public void save(String graphName, Model model) { public void switchInstances(it.gov.innovazione.ndc.model.harvester.Repository repository) { String tmpGraphName = reworkRepoUrlIfNecessary(repository.getUrl(), TMP_GRAPH_PREFIX); + log.info("Switching instances on Virtuoso ({}, {})", repository.getUrl(), tmpGraphName); clearExistingNamedGraph(repository.getUrl()); rename(tmpGraphName, repository.getUrl()); } diff --git a/src/main/java/it/gov/innovazione/ndc/service/DefaultInstanceManager.java b/src/main/java/it/gov/innovazione/ndc/service/DefaultInstanceManager.java index a4a3d0f..8ea4f05 100644 --- a/src/main/java/it/gov/innovazione/ndc/service/DefaultInstanceManager.java +++ b/src/main/java/it/gov/innovazione/ndc/service/DefaultInstanceManager.java @@ -7,6 +7,7 @@ import it.gov.innovazione.ndc.repository.SemanticAssetMetadataDeleter; import it.gov.innovazione.ndc.repository.TripleStoreRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.List; @@ -17,6 +18,7 @@ @Service @RequiredArgsConstructor +@Slf4j public class DefaultInstanceManager implements InstanceManager { private final ConfigService configService; @@ -47,13 +49,21 @@ public Instance getCurrentInstance(Repository repository) { public void switchInstances(Repository repository) { // switch instance on Repositories + log.info("Switching instance for repository {}", repository.getUrl()); Instance newInstance = getNextOnlineInstance(repository); + + log.info("Switching Elastic search to instance {} for repo {}", newInstance, repository.getUrl()); + configService.writeConfigKey(ACTIVE_INSTANCE, "system", newInstance, repository.getId()); Instance instanceToDelete = newInstance.switchInstance(); + log.info("Deleting metadata for instance {} for repo {}", instanceToDelete, repository.getUrl()); + deleter.deleteByRepoUrl(repository.getUrl(), instanceToDelete); + log.info("Switching instances on Virtuoso for repo {}", repository.getUrl()); + // switch instance on Virtuoso tripleStoreRepository.switchInstances(repository); } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 71fcaba..e14d0ac 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -1,4 +1,4 @@ -harvester.repositories=https://github.com/istat/ts-ontologie-vocabolari-controllati +harvester.repositories=https://github.com/FrankMaverick/Leo-OpenData virtuoso.sparql=http://localhost:8890/sparql-auth virtuoso.sparql-graph-store=http://localhost:8890/sparql-graph-crud-auth From 2fe2e2e1e47479f2dcf44b701f22c1b060edae46 Mon Sep 17 00:00:00 2001 From: ndc-dxc Date: Wed, 16 Oct 2024 13:36:19 +0200 Subject: [PATCH 2/2] implementazione da codice invece che da openapi --- .../it/gov/innovazione/ndc/Application.java | 32 +++++++++++++++++++ .../controller/AbstractCrudController.java | 21 ++++++++++++ .../ApplicationStatusController.java | 28 ++++++++++------ .../ndc/controller/CheckUrlController.java | 16 ++++++++++ .../controller/ConfigurationController.java | 17 ++++++++++ .../ndc/controller/HarvestJobController.java | 25 +++++++++++++++ .../ndc/controller/RepositoryController.java | 17 ++++++++++ .../ndc/controller/ValidationController.java | 5 +++ src/main/resources/application.properties | 5 ++- 9 files changed, 153 insertions(+), 13 deletions(-) diff --git a/src/main/java/it/gov/innovazione/ndc/Application.java b/src/main/java/it/gov/innovazione/ndc/Application.java index 4a21889..e0abdbd 100644 --- a/src/main/java/it/gov/innovazione/ndc/Application.java +++ b/src/main/java/it/gov/innovazione/ndc/Application.java @@ -1,5 +1,9 @@ package it.gov.innovazione.ndc; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -7,6 +11,34 @@ import java.time.Clock; @SpringBootApplication +@OpenAPIDefinition( + info = @Info( + title = "Schema - Semantic Backend", + version = "0.0.1", + description = """ + This API exposes information from Schema, the National Data Catalog for Semantic Interoperability including the REST API + for accessing controlled vocabularies. + + + It is used as a backend service for the [schema.gov.it](https://schema.gov.it) website and to expose functionalities in + an interoperable way. + + + Provided information can be used to discover ontologies, controlled vocabularies and schemas indexed by Schema, and to + ease the creation of semantically interoperable digital services such as web forms and APIs. + + + **This API is a beta release, and it can change in the future during the consolidation phase of Schema.**""", + contact = @Contact( + name = "Dipartimento per la Trasformazione digitale", + email = "info@teamdigitale.governo.it"), + license = @License( + name = " BSD-3-Clause", + url = "https://opensource.org/licenses/BSD-3-Clause"), + summary = "Expose ontology, controlled vocabularies and schemas information from Schema." + + + )) public class Application { public static void main(String[] args) { diff --git a/src/main/java/it/gov/innovazione/ndc/alerter/controller/AbstractCrudController.java b/src/main/java/it/gov/innovazione/ndc/alerter/controller/AbstractCrudController.java index 1fb5fc1..91576d4 100644 --- a/src/main/java/it/gov/innovazione/ndc/alerter/controller/AbstractCrudController.java +++ b/src/main/java/it/gov/innovazione/ndc/alerter/controller/AbstractCrudController.java @@ -1,6 +1,7 @@ package it.gov.innovazione.ndc.alerter.controller; +import io.swagger.v3.oas.annotations.Operation; import it.gov.innovazione.ndc.alerter.data.EntityService; import it.gov.innovazione.ndc.alerter.dto.SlimPager; import it.gov.innovazione.ndc.alerter.entities.Nameable; @@ -27,6 +28,10 @@ public abstract class AbstractCrudController getEntityService(); @GetMapping + @Operation( + operationId = "getAll", + description = "Get all entities", + summary = "Get all entities") public SlimPager getPaginated(Pageable pageable) { return toSlimPager(getEntityService().getPaginated(pageable)); } @@ -50,12 +55,20 @@ private SlimPager toSlimPager(Page paginated) { } @GetMapping("{id}") + @Operation( + operationId = "getOne", + description = "Get one entity", + summary = "Get one entity") public D getOne(@PathVariable String id) { return getEntityService().getById(id); } @PostMapping @ResponseStatus(CREATED) + @Operation( + operationId = "create", + description = "Create a new entity", + summary = "Create a new entity") public D create(@Valid @RequestBody D dto) { handlePreCreate(dto); D createdEntity = getEntityService().create(dto); @@ -73,6 +86,10 @@ protected void handlePostCreate(D createdEntity) { @PatchMapping @ResponseStatus(CREATED) + @Operation( + operationId = "update", + description = "Update an entity", + summary = "Update an entity") public D update(@Valid @RequestBody D dto) { handlePreUpdate(dto); D updatedDto = getEntityService().update(dto); @@ -90,6 +107,10 @@ protected void handlePostUpdate(D updatedDto) { @DeleteMapping("{id}") @ResponseStatus(CREATED) + @Operation( + operationId = "delete", + description = "Delete an entity", + summary = "Delete an entity") public void delete(@PathVariable String id) { handlePreDelete(id); D deletedDto = getEntityService().delete(id); diff --git a/src/main/java/it/gov/innovazione/ndc/controller/ApplicationStatusController.java b/src/main/java/it/gov/innovazione/ndc/controller/ApplicationStatusController.java index ec056b4..4b0114b 100644 --- a/src/main/java/it/gov/innovazione/ndc/controller/ApplicationStatusController.java +++ b/src/main/java/it/gov/innovazione/ndc/controller/ApplicationStatusController.java @@ -1,5 +1,7 @@ package it.gov.innovazione.ndc.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import it.gov.innovazione.ndc.gen.dto.Problem; import it.gov.innovazione.ndc.model.Builders; import lombok.RequiredArgsConstructor; @@ -15,27 +17,33 @@ @RestController @RequiredArgsConstructor +@Tag(name = "status", description = "Entry point for application status") public class ApplicationStatusController { private final HealthEndpoint healthEndpoint; @GetMapping("/status") + @Operation( + operationId = "checkStatus", + description = "Check if the application is available and healthy", + tags = {"status"}, + summary = "Check the application status") public ResponseEntity getStatus() { Status status = healthEndpoint.health().getStatus(); if (status != Status.UP) { Problem response = Builders.problem() - .status(INTERNAL_SERVER_ERROR) - .title("Application is not available") - .build(); + .status(INTERNAL_SERVER_ERROR) + .title("Application is not available") + .build(); return ResponseEntity - .status(INTERNAL_SERVER_ERROR) - .contentType(MediaType.APPLICATION_PROBLEM_JSON) - .body(response); + .status(INTERNAL_SERVER_ERROR) + .contentType(MediaType.APPLICATION_PROBLEM_JSON) + .body(response); } return ResponseEntity.status(OK.value()) - .contentType(MediaType.APPLICATION_PROBLEM_JSON) - .body(Builders.problem() - .status(OK) - .title("Application is available").build()); + .contentType(MediaType.APPLICATION_PROBLEM_JSON) + .body(Builders.problem() + .status(OK) + .title("Application is available").build()); } } diff --git a/src/main/java/it/gov/innovazione/ndc/controller/CheckUrlController.java b/src/main/java/it/gov/innovazione/ndc/controller/CheckUrlController.java index 8817934..4729544 100644 --- a/src/main/java/it/gov/innovazione/ndc/controller/CheckUrlController.java +++ b/src/main/java/it/gov/innovazione/ndc/controller/CheckUrlController.java @@ -1,5 +1,9 @@ package it.gov.innovazione.ndc.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -16,8 +20,20 @@ @RequestMapping("check-url") @Slf4j public class CheckUrlController { + @GetMapping @SneakyThrows + @Operation( + operationId = "checkUrl", + description = "Check if the passed URL is available", + summary = "Check the URL status", + responses = { + @ApiResponse(responseCode = "200", description = "The URL is available", + content = @Content(schema = @Schema(implementation = HttpStatus.class))), + @ApiResponse(responseCode = "404", description = "The URL is not available", + content = @Content(schema = @Schema(implementation = HttpStatus.class))), + @ApiResponse(responseCode = "500", description = "The URL is not available", + content = @Content(schema = @Schema(implementation = HttpStatus.class)))}) public ResponseEntity check(@RequestParam String url) { log.info("Checking url {}", url); HttpURLConnection huc = (HttpURLConnection) new URL(url).openConnection(); diff --git a/src/main/java/it/gov/innovazione/ndc/controller/ConfigurationController.java b/src/main/java/it/gov/innovazione/ndc/controller/ConfigurationController.java index 7660195..8e1f474 100644 --- a/src/main/java/it/gov/innovazione/ndc/controller/ConfigurationController.java +++ b/src/main/java/it/gov/innovazione/ndc/controller/ConfigurationController.java @@ -1,5 +1,6 @@ package it.gov.innovazione.ndc.controller; +import io.swagger.v3.oas.annotations.Operation; import it.gov.innovazione.ndc.eventhandler.NdcEventPublisher; import it.gov.innovazione.ndc.eventhandler.event.ConfigService; import it.gov.innovazione.ndc.harvester.service.ActualConfigService; @@ -32,6 +33,10 @@ public class ConfigurationController { private final NdcEventPublisher eventPublisher; @GetMapping + @Operation( + operationId = "getConfig", + description = "Get the configuration for a repository", + summary = "Get the configuration for a repository") public Map getConfig( @PathVariable String repoId) { if (repoId.equals("ndc")) { @@ -42,6 +47,10 @@ public Map getConfig( @PostMapping @ResponseStatus(CREATED) + @Operation( + operationId = "setConfig", + description = "Set the configuration for a repository", + summary = "Set the configuration for a repository") public void setConfig( @PathVariable String repoId, @RequestBody Map config, @@ -55,6 +64,10 @@ public void setConfig( @PutMapping("/{configKey}") @ResponseStatus(ACCEPTED) + @Operation( + operationId = "updateRepository", + description = "Update a configuration key for a repository", + summary = "Update a configuration key for a repository") public void updateRepository( @PathVariable String repoId, @PathVariable ActualConfigService.ConfigKey configKey, @@ -69,6 +82,10 @@ public void updateRepository( @DeleteMapping("/{configKey}") @ResponseStatus(ACCEPTED) + @Operation( + operationId = "deleteRepository", + description = "Delete a configuration key for a repository", + summary = "Delete a configuration key for a repository") public void deleteRepository( @PathVariable String repoId, @PathVariable ActualConfigService.ConfigKey configKey, diff --git a/src/main/java/it/gov/innovazione/ndc/controller/HarvestJobController.java b/src/main/java/it/gov/innovazione/ndc/controller/HarvestJobController.java index 51012a9..000584c 100644 --- a/src/main/java/it/gov/innovazione/ndc/controller/HarvestJobController.java +++ b/src/main/java/it/gov/innovazione/ndc/controller/HarvestJobController.java @@ -1,5 +1,6 @@ package it.gov.innovazione.ndc.controller; +import io.swagger.v3.oas.annotations.Operation; import it.gov.innovazione.ndc.alerter.entities.EventCategory; import it.gov.innovazione.ndc.alerter.entities.Severity; import it.gov.innovazione.ndc.alerter.event.AlertableEvent; @@ -40,6 +41,10 @@ public class HarvestJobController { private final NdcEventPublisher eventPublisher; @PostMapping("jobs/harvest") + @Operation( + operationId = "startHarvestJob", + description = "Start a new harvest job", + summary = "Start a new harvest job") public List startHarvestJob(@RequestParam(required = false, defaultValue = "false") Boolean force) { log.info("Starting Harvest job at " + LocalDateTime.now()); List harvest = harvesterJob.harvest(force); @@ -53,16 +58,28 @@ public List startHarvestJob(@RequestParam(required = false } @GetMapping("jobs/harvest/run") + @Operation( + operationId = "getHarvestRuns", + description = "Get all harvest runs", + summary = "Get all harvest runs") public List getAllRuns() { return harvesterRunService.getAllRuns(); } @GetMapping("jobs/harvest/running") + @Operation( + operationId = "getRunningInstances", + description = "Get all running instances", + summary = "Get all running instances") public List getAllRunningInstance() { return harvesterRunService.getAllRunningInstances(); } @DeleteMapping("jobs/harvest/run") + @Operation( + operationId = "deletePendingRuns", + description = "Delete all pending runs", + summary = "Delete all pending runs") public void deletePendingRuns() { harvesterRunService.deletePendingRuns(); eventPublisher.publishAlertableEvent( @@ -73,6 +90,10 @@ public void deletePendingRuns() { } @PostMapping(value = "jobs/harvest", params = "repositoryId") + @Operation( + operationId = "harvestRepositories", + description = "Harvest a specific repository", + summary = "Harvest a specific repository") public JobExecutionResponse harvestRepositories( @RequestParam("repositoryId") String repositoryId, @RequestParam(required = false, defaultValue = "") String revision, @@ -90,6 +111,10 @@ public JobExecutionResponse harvestRepositories( @PostMapping("jobs/clear") @ResponseStatus(HttpStatus.ACCEPTED) + @Operation( + operationId = "clearRepo", + description = "Clear a repository", + summary = "Clear a repository") public void clearRepo(@RequestParam("repo_url") String repoUrl) { if (StringUtils.isEmpty(repoUrl)) { throw new IllegalArgumentException("repo_url is required"); diff --git a/src/main/java/it/gov/innovazione/ndc/controller/RepositoryController.java b/src/main/java/it/gov/innovazione/ndc/controller/RepositoryController.java index 1799e13..f8699eb 100644 --- a/src/main/java/it/gov/innovazione/ndc/controller/RepositoryController.java +++ b/src/main/java/it/gov/innovazione/ndc/controller/RepositoryController.java @@ -1,5 +1,6 @@ package it.gov.innovazione.ndc.controller; +import io.swagger.v3.oas.annotations.Operation; import it.gov.innovazione.ndc.alerter.entities.EventCategory; import it.gov.innovazione.ndc.alerter.entities.Severity; import it.gov.innovazione.ndc.alerter.event.DefaultAlertableEvent; @@ -43,6 +44,10 @@ public class RepositoryController { private final NdcEventPublisher eventPublisher; @GetMapping + @Operation( + operationId = "getAllRepositories", + description = "Get all repositories", + summary = "Get all repositories") public List getAllRepositories() { return repositoryService.getActiveRepos(); } @@ -50,6 +55,10 @@ public List getAllRepositories() { @PostMapping @ResponseStatus(CREATED) @SneakyThrows + @Operation( + operationId = "createRepository", + description = "Create a new repository", + summary = "Create a new repository") public void createRepository( @RequestBody CreateRepository repository, Principal principal) { @@ -86,6 +95,10 @@ private void assertValidUrl(@RequestBody CreateRepository repository) throws Bad @PatchMapping("/{id}") @SneakyThrows + @Operation( + operationId = "updateRepository", + description = "Update a repository", + summary = "Update a repository") public ResponseEntity updateRepository( @PathVariable String id, @RequestBody CreateRepository repository, @@ -119,6 +132,10 @@ public ResponseEntity updateRepository( @DeleteMapping("/{id}") @SneakyThrows + @Operation( + operationId = "deleteRepository", + description = "Delete a repository", + summary = "Delete a repository") public ResponseEntity deleteRepository( @PathVariable String id, Principal principal) { diff --git a/src/main/java/it/gov/innovazione/ndc/controller/ValidationController.java b/src/main/java/it/gov/innovazione/ndc/controller/ValidationController.java index 453b158..7df305d 100644 --- a/src/main/java/it/gov/innovazione/ndc/controller/ValidationController.java +++ b/src/main/java/it/gov/innovazione/ndc/controller/ValidationController.java @@ -1,5 +1,6 @@ package it.gov.innovazione.ndc.controller; +import io.swagger.v3.oas.annotations.Operation; import it.gov.innovazione.ndc.service.ValidationService; import it.gov.innovazione.ndc.validator.ValidationResultDto; import lombok.RequiredArgsConstructor; @@ -18,6 +19,10 @@ public class ValidationController { private final ValidationService validationService; @PostMapping + @Operation( + operationId = "validateFile", + description = "Validate the file representing a semantic asset", + summary = "Validate the file") public ResponseEntity validateFile(@RequestParam(value = "type") String assetType, @RequestParam(value = "file") MultipartFile file) { return AppJsonResponse.ok(validationService.validate(file, assetType)); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index eb2d351..6b1aec8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -25,9 +25,8 @@ harvester.controlled-vocabulary.scanner.skip-words=transparency-obligation-organ harvester.auth.user=${HARVESTER_USER:harv-user} harvester.auth.password=${HARVESTER_PASSWORD:harv-password} - -springdoc.api-docs.enabled=false -springdoc.swagger-ui.url=/openapi.yaml +springdoc.api-docs.enabled=true +#springdoc.swagger-ui.url=/openapi.yaml #Disable restrictions on multipart requests to validate semantic assets files spring.servlet.multipart.max-file-size=-1 spring.servlet.multipart.max-request-size=-1