Skip to content

Commit

Permalink
API / Improve OpenAPI spec schema.
Browse files Browse the repository at this point in the history
* /site response is using SettingsListToObjectSerializer which returns a simple object
* OpenAPI generator does not generate parameters for process API.
  • Loading branch information
fxprunayre committed Jan 14, 2025
1 parent d46fa20 commit d63cc9e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions services/src/main/java/org/fao/geonet/api/OpenApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
package org.fao.geonet.api;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariable;
import io.swagger.v3.oas.models.servers.ServerVariables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
package org.fao.geonet.api.records;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.Explode;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.enums.ParameterStyle;
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 Down Expand Up @@ -167,7 +171,15 @@ ResponseEntity<Element> processRecordPreview(
public @ResponseBody
ResponseEntity processRecord(
@Parameter(description = API_PARAM_RECORD_UUID, required = true) @PathVariable String metadataUuid,
@Parameter(description = ApiParams.API_PARAM_PROCESS_ID) @PathVariable String process, HttpServletRequest request)
@Parameter(description = ApiParams.API_PARAM_PROCESS_ID, example = "thumbnail-add") @PathVariable String process,
@Parameter(name = "processParams", description = "Parameters to pass to the process",
in = ParameterIn.QUERY,
required = false,
schema = @Schema(type = "object", additionalProperties = Schema.AdditionalPropertiesValue.TRUE, example = "{\"thumbnail_url\":\"http://\",\"thumbnail_desc\":\"Dataset overview\"}"),
style = ParameterStyle.FORM,
explode = Explode.TRUE)
@RequestParam(required = false) Map<String,String> processParams,
HttpServletRequest request)
throws Exception {
AbstractMetadata metadata = ApiUtils.canEditRecord(metadataUuid, request);
boolean save = true;
Expand Down
20 changes: 19 additions & 1 deletion services/src/main/java/org/fao/geonet/api/site/SiteApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,29 @@ public static void reloadServices(ServiceContext context) throws Exception {
summary = "Get site (or portal) description",
description = "")
@RequestMapping(
consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.ALL_VALUE},
produces = MediaType.APPLICATION_JSON_VALUE,
method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Site description.")
@ApiResponse(responseCode = "200", description = "Site description.",
content = {
@Content(schema = @Schema(
type = "object",
additionalPropertiesSchema = String.class
),
examples = @ExampleObject(value = "{\n" +
" \"system/site/name\": \"My GeoNetwork catalogue\",\n" +
" \"system/site/organization\": \"My organization\",\n" +
" \"system/site/siteId\": \"33bc8c82-7ac2-49b6-a22b-af7376dbcf10\",\n" +
" \"system/platform/version\": \"4.4.7\",\n" +
" \"system/platform/subVersion\": \"SNAPSHOT\",\n" +
" \"node/default\": \"true\",\n" +
" \"node/id\": \"33bc8c82-7ac2-49b6-a22b-af7376dbcf10\",\n" +
" \"node/name\": \"My GeoNetwork catalogue\",\n" +
" \"microservices/enabled\": false\n" +
"}"))
})
})
@ResponseBody
public SettingsListResponse getSiteOrPortalDescription(
Expand Down

0 comments on commit d63cc9e

Please sign in to comment.