Skip to content

Commit

Permalink
OpenAPI / Operation returning no content should not advertised a schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Sep 23, 2024
1 parent 1a780ac commit 51ee3df
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@


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 Down Expand Up @@ -107,7 +109,7 @@ public class AtomDescribe {
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Feeds."),
@ApiResponse(responseCode = "204", description = "Not authenticated.")
@ApiResponse(responseCode = "204", description = "Not authenticated.", content = {@Content(schema = @Schema(hidden = true))})
})
@ResponseStatus(OK)
@ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package org.fao.geonet.services.inspireatom;

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 Down Expand Up @@ -84,7 +86,7 @@ public class AtomGetData {
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Get a data file related to dataset"),
@ApiResponse(responseCode = "204", description = "Not authenticated.")
@ApiResponse(responseCode = "204", description = "Not authenticated.", content = {@Content(schema = @Schema(hidden = true))})
})
@ResponseStatus(OK)
@ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package org.fao.geonet.services.inspireatom;

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 Down Expand Up @@ -61,7 +63,7 @@ public class AtomHarvester {
@PreAuthorize("hasAuthority('Administrator')")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Scan completed."),
@ApiResponse(responseCode = "204", description = "Not authenticated.")
@ApiResponse(responseCode = "204", description = "Not authenticated.", content = {@Content(schema = @Schema(hidden = true))})
})
@ResponseStatus(CREATED)
@ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Parameter;
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 @@ -114,7 +115,7 @@ public class AtomSearch {
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Get a list of feeds."),
@ApiResponse(responseCode = "204", description = "Not authenticated.")
@ApiResponse(responseCode = "204", description = "Not authenticated.", content = {@io.swagger.v3.oas.annotations.media.Content(schema = @Schema(hidden = true))})
})
@ResponseStatus(OK)
public Object feeds(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package org.fao.geonet.services.inspireatom;

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 Down Expand Up @@ -91,7 +93,7 @@ public class AtomServiceDescription {
produces = MediaType.APPLICATION_XML_VALUE)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Feeds."),
@ApiResponse(responseCode = "204", description = "Not authenticated.")
@ApiResponse(responseCode = "204", description = "Not authenticated.", content = {@Content(schema = @Schema(hidden = true))})
})
@ResponseStatus(OK)
@ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.api.categories;

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 Down Expand Up @@ -180,7 +182,7 @@ public org.fao.geonet.domain.MetadataCategory getTag(
@PreAuthorize("hasAuthority('UserAdmin')")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Tag updated."),
@ApiResponse(responseCode = "204", description = "Tag updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN)
})
@ResponseBody
Expand Down Expand Up @@ -239,7 +241,7 @@ private void updateCategory(
method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Tag removed."),
@ApiResponse(responseCode = "204", description = "Tag removed.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN)
})
@PreAuthorize("hasAuthority('UserAdmin')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.google.common.base.Functions;
import com.google.common.collect.Lists;
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 Down Expand Up @@ -430,7 +432,7 @@ public List<User> getGroupUsers(
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@PreAuthorize("hasAuthority('UserAdmin')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Group updated."),
@ApiResponse(responseCode = "204", description = "Group updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN)
})
Expand Down Expand Up @@ -485,7 +487,7 @@ public void updateGroup(
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@PreAuthorize("hasAuthority('Administrator')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Group removed."),
@ApiResponse(responseCode = "204", description = "Group removed.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.api.harvesting;

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 Down Expand Up @@ -98,7 +100,7 @@ public class HarvestersApi {
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@PreAuthorize("hasAuthority('UserAdmin')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Harvester records transfered to new source."),
@ApiResponse(responseCode = "204", description = "Harvester records transfered to new source.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.api.identifiers;

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 Down Expand Up @@ -153,7 +155,7 @@ public ResponseEntity<Integer> addIdentifier(
)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Identifier template updated."),
@ApiResponse(responseCode = "204", description = "Identifier template updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = "Resource not found."),
@ApiResponse(responseCode = "403", description = "Operation not allowed. Only Editor can access it.")
})
Expand Down Expand Up @@ -198,7 +200,7 @@ public void updateIdentifier(
)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Template identifier removed."),
@ApiResponse(responseCode = "204", description = "Template identifier removed.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = "Resource not found."),
@ApiResponse(responseCode = "403", description = "Operation not allowed. Only Editor can access it.")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.api.languages;

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 Down Expand Up @@ -185,7 +187,7 @@ public void addLanguages(
@PreAuthorize("hasAuthority('Administrator')")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Language translations removed."),
@ApiResponse(responseCode = "204", description = "Language translations removed.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = "Resource not found."),
@ApiResponse(responseCode = "403", description = "Operation not allowed. Only Administrator can access it.")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.api.mapservers;

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 Down Expand Up @@ -209,7 +211,7 @@ public ResponseEntity<Integer> addMapserver(
})
@PreAuthorize("hasAuthority('Reviewer')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Mapserver updated."),
@ApiResponse(responseCode = "204", description = "Mapserver updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_REVIEWER)
})
Expand Down Expand Up @@ -253,7 +255,7 @@ public void updateMapserver(
})
@PreAuthorize("hasAuthority('Reviewer')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Mapserver updated."),
@ApiResponse(responseCode = "204", description = "Mapserver updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_REVIEWER)
})
Expand Down Expand Up @@ -323,7 +325,7 @@ private void updateMapserver(
})
@PreAuthorize("hasAuthority('Reviewer')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Mapserver removed."),
@ApiResponse(responseCode = "204", description = "Mapserver removed.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = ApiParams.API_RESPONSE_RESOURCE_NOT_FOUND),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_REVIEWER)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.fao.geonet.api.processing;

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 Down Expand Up @@ -99,7 +101,7 @@ public List<ProcessingReport> getProcessReport() throws Exception {
MediaType.APPLICATION_JSON_VALUE
})
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Report registry cleared."),
@ApiResponse(responseCode = "204", description = "Report registry cleared.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_AUTHENTICATED)
})
@ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package org.fao.geonet.api.records;

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 Down Expand Up @@ -182,7 +184,7 @@ ResponseEntity<Map<String, String>> createDoi(
)
@PreAuthorize("hasAuthority('Administrator')")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "DOI unregistered."),
@ApiResponse(responseCode = "204", description = "DOI unregistered.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "404", description = "Metadata or DOI not found."),
@ApiResponse(responseCode = "500", description = "Service unavailable."),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_ADMIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
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 Down Expand Up @@ -206,7 +208,7 @@ public class MetadataInsertDeleteApi {
+ "from the index and then from the database.")
@RequestMapping(value = "/{metadataUuid}", method = RequestMethod.DELETE)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Record deleted."),
@ApiResponse(responseCode = "204", description = "Record deleted.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "401", description = "This template is referenced"),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import com.google.common.base.Optional;
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 Down Expand Up @@ -215,7 +217,7 @@ public List<PublicationOption> getPublicationOptions() {
method = RequestMethod.PUT
)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Settings updated."),
@ApiResponse(responseCode = "204", description = "Settings updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)
})
@PreAuthorize("hasAuthority('Reviewer')")
Expand Down Expand Up @@ -260,7 +262,7 @@ public void publish(
method = RequestMethod.PUT
)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Settings updated."),
@ApiResponse(responseCode = "204", description = "Settings updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)
})
@PreAuthorize("hasAuthority('Reviewer')")
Expand Down Expand Up @@ -314,7 +316,7 @@ public void unpublish(
method = RequestMethod.PUT
)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Settings updated."),
@ApiResponse(responseCode = "204", description = "Settings updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)
})
@PreAuthorize("hasAuthority('Editor')")
Expand Down Expand Up @@ -775,7 +777,7 @@ public SharingResponse getRecordSharingSettings(
method = RequestMethod.PUT
)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Record group updated."),
@ApiResponse(responseCode = "204", description = "Record group updated.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)
})
@PreAuthorize("hasAuthority('Editor')")
Expand Down Expand Up @@ -818,9 +820,9 @@ public void setRecordGroup(
metadataManager.save(metadata);
dataManager.indexMetadata(String.valueOf(metadata.getId()), true);

new RecordGroupOwnerChangeEvent(metadata.getId(),
ApiUtils.getUserSession(request.getSession()).getUserIdAsInt(),
ObjectJSONUtils.convertObjectInJsonObject(oldGroup, RecordGroupOwnerChangeEvent.FIELD),
new RecordGroupOwnerChangeEvent(metadata.getId(),
ApiUtils.getUserSession(request.getSession()).getUserIdAsInt(),
ObjectJSONUtils.convertObjectInJsonObject(oldGroup, RecordGroupOwnerChangeEvent.FIELD),
ObjectJSONUtils.convertObjectInJsonObject(group.get(), RecordGroupOwnerChangeEvent.FIELD)).publish(appContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import com.google.common.collect.Sets;
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 Down Expand Up @@ -212,7 +214,7 @@ private void indexTags(AbstractMetadata metadata) throws Exception {
@DeleteMapping(value = "/{metadataUuid}/tags")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Record tags removed."),
@ApiResponse(responseCode = "204", description = "Record tags removed.", content = {@Content(schema = @Schema(hidden = true))}),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_EDIT)
})
@PreAuthorize("hasAuthority('Editor')")
Expand Down
Loading

0 comments on commit 51ee3df

Please sign in to comment.