diff --git a/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java b/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java index 908b7f314ae..b1b27ecfa30 100644 --- a/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java +++ b/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java @@ -1,6 +1,6 @@ /* * ============================================================================= - * === Copyright (C) 2001-2016 Food and Agriculture Organization of the + * === Copyright (C) 2001-2023 Food and Agriculture Organization of the * === United Nations (FAO-UN), United Nations World Food Programme (WFP) * === and United Nations Environment Programme (UNEP) * === @@ -29,6 +29,8 @@ import static org.fao.geonet.api.ApiParams.API_CLASS_RECORD_TAG; import io.swagger.v3.oas.annotations.Parameter; +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 io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -44,13 +46,10 @@ import org.fao.geonet.events.history.AttachmentDeletedEvent; import org.fao.geonet.util.ImageUtil; import org.springframework.context.ApplicationContext; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; -import org.springframework.util.MultiValueMap; import org.springframework.util.StreamUtils; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; @@ -68,7 +67,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URL; import java.nio.file.Files; @@ -201,7 +199,9 @@ public void delResources( @io.swagger.v3.oas.annotations.Operation(summary = "Create a new resource for a given metadata") @PreAuthorize("hasAuthority('Editor')") - @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(method = RequestMethod.POST, + consumes = MediaType.ALL_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.CREATED) @ApiResponses(value = {@ApiResponse(responseCode = "201", description = "Attachment uploaded."), @ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)}) @@ -257,7 +257,8 @@ public MetadataResource putResourceFromURL( // @PreAuthorize("permitAll") @RequestMapping(value = "/{resourceId:.+}", method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.OK) - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Record attachment."), + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Record attachment.", + content = @Content(schema = @Schema(type = "string", format = "binary"))), @ApiResponse(responseCode = "403", description = "Operation not allowed. " + "User needs to be able to download the resource.")}) public void getResource( diff --git a/services/src/main/java/org/fao/geonet/api/registries/vocabularies/KeywordsApi.java b/services/src/main/java/org/fao/geonet/api/registries/vocabularies/KeywordsApi.java index d28d7507a6c..956d616f55b 100644 --- a/services/src/main/java/org/fao/geonet/api/registries/vocabularies/KeywordsApi.java +++ b/services/src/main/java/org/fao/geonet/api/registries/vocabularies/KeywordsApi.java @@ -24,6 +24,7 @@ package org.fao.geonet.api.registries.vocabularies; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -634,7 +635,8 @@ private Object getKeyword( MediaType.TEXT_XML_VALUE }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Thesaurus in SKOS format."), + @ApiResponse(responseCode = "200", description = "Thesaurus in SKOS format.", + content = @Content(schema = @io.swagger.v3.oas.annotations.media.Schema(type = "string", format = "binary"))), @ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND) }) @ResponseBody