Skip to content

Commit

Permalink
Fix spring doc for attachment and keyword to better identify files re…
Browse files Browse the repository at this point in the history
…sources being returned.

Update attachment api
   "Get a metadata resource" should indicate that gets a file resource
   Also "Create a new resource" should identify that it consumes any resources
Update keywords api
   "Download a thesaurus by name" should indicate that gets a file resource
  • Loading branch information
ianwallen committed Feb 2, 2024
1 parent 7aa83b1 commit 4cbb041
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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)
* ===
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)})
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4cbb041

Please sign in to comment.