Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump elideVersion from 7.0.0-pr4 to 7.0.0-pr6 #764

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ dependencies {
runtimeOnly("org.mariadb.jdbc:mariadb-java-client")

// Manually managed dependencies
def elideVersion = "7.0.0-pr4"
def elideVersion = "7.0.0-pr6"
def springdocVersion = "2.1.0"
implementation("com.yahoo.elide:elide-core:${elideVersion}")
implementation("com.yahoo.elide:elide-model-config:${elideVersion}")
Expand Down
46 changes: 24 additions & 22 deletions src/main/java/com/faforever/api/avatar/AvatarController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.faforever.api.error.ErrorResponse;
import com.faforever.api.security.OAuthScope;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
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 org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -31,51 +33,51 @@ public AvatarController(AvatarService avatarService) {
this.avatarService = avatarService;
}

@ApiOperation(value = "Upload avatar", notes = """
@Operation(summary = "Upload avatar", description = """
Avatar metadata - {
"name": "String"
}""")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Success"),
@ApiResponse(code = 422, message = "Invalid input", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Failure", response = ErrorResponse.class)})
@ApiResponse(responseCode = "201", description = "Success"),
@ApiResponse(responseCode = "422", description = "Invalid input", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "Failure", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))})
@ResponseStatus(value = HttpStatus.CREATED)
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasScope('" + OAuthScope._ADMINISTRATIVE_ACTION + "') and hasAnyRole('" + ROLE_WRITE_AVATAR + "', 'ROLE_ADMINISTRATOR')")
public void uploadAvatar(
@ApiParam(name = "metadata") @RequestPart("metadata") AvatarMetadata avatarMetaData,
@ApiParam(name = "file") @RequestPart("file") MultipartFile avatarImageFile) throws IOException {
@Parameter(name = "metadata") @RequestPart("metadata") AvatarMetadata avatarMetaData,
@Parameter(name = "file") @RequestPart("file") MultipartFile avatarImageFile) throws IOException {
avatarService.createAvatar(avatarMetaData, avatarImageFile.getOriginalFilename(), avatarImageFile.getInputStream(), avatarImageFile.getSize());
}

@ApiOperation(value = "Update/Reupload avatar", notes = "Avatar metadata - " +
@Operation(summary = "Update/Reupload avatar", description = "Avatar metadata - " +
"{" +
" \"name\": \"String\"" +
"}")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 422, message = "Invalid input", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Failure", response = ErrorResponse.class)})
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "422", description = "Invalid input", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "Failure", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))})
@ResponseStatus(value = HttpStatus.OK)
@RequestMapping(value = "{avatarId}/upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasScope('" + OAuthScope._ADMINISTRATIVE_ACTION + "') and hasAnyRole('" + ROLE_WRITE_AVATAR + "', 'ROLE_ADMINISTRATOR')")
public void reuploadAvatar(
@ApiParam(name = "avatarId") @PathVariable("avatarId") Integer avatarId,
@ApiParam(name = "metadata") @RequestPart(value = "metadata") AvatarMetadata avatarMetaData,
@ApiParam(name = "file") @RequestPart("file") MultipartFile avatarImageFile) throws IOException {
@Parameter(name = "avatarId") @PathVariable("avatarId") Integer avatarId,
@Parameter(name = "metadata") @RequestPart(value = "metadata") AvatarMetadata avatarMetaData,
@Parameter(name = "file") @RequestPart("file") MultipartFile avatarImageFile) throws IOException {
avatarService.updateAvatar(avatarId, avatarMetaData, avatarImageFile.getOriginalFilename(), avatarImageFile.getInputStream(), avatarImageFile.getSize());
}

@ApiOperation(value = "Delete avatar")
@Operation(summary = "Delete avatar")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Success"),
@ApiResponse(code = 422, message = "Invalid input", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Failure", response = ErrorResponse.class)})
@ApiResponse(responseCode = "204", description = "Success"),
@ApiResponse(responseCode = "422", description = "Invalid input", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "Failure", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@RequestMapping(value = "/{avatarId}", method = RequestMethod.DELETE)
@PreAuthorize("hasScope('" + OAuthScope._ADMINISTRATIVE_ACTION + "') and hasAnyRole('" + ROLE_WRITE_AVATAR + "', 'ROLE_ADMINISTRATOR')")
public void deleteAvatar(
@ApiParam(name = "avatarId") @PathVariable("avatarId") Integer avatarId) throws IOException {
@Parameter(name = "avatarId") @PathVariable("avatarId") Integer avatarId) throws IOException {
avatarService.deleteAvatar(avatarId);
}

Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/faforever/api/clan/ClansController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.faforever.api.data.domain.Clan;
import com.faforever.api.data.domain.Player;
import com.faforever.api.player.PlayerService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
Expand All @@ -35,10 +35,10 @@ public class ClansController {
private final ClanService clanService;
private final PlayerService playerService;

@ApiOperation("Grab data about yourself and the clan")
@Operation(summary = "Grab data about yourself and the clan")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success with JSON { player: {id: ?, login: ?}, clan: { id: ?, name: ?, tag: ?}}"),
@ApiResponse(code = 400, message = "Bad Request")})
@ApiResponse(responseCode = "200", description = "Success with JSON { player: {id: ?, login: ?}, clan: { id: ?, name: ?, tag: ?}}"),
@ApiResponse(responseCode = "400", description = "Bad Request")})
@GetMapping(path = "/me", produces = APPLICATION_JSON_VALUE)
public MeResult me(Authentication authentication) {
Player player = playerService.getPlayer(authentication);
Expand All @@ -53,10 +53,10 @@ public MeResult me(Authentication authentication) {

// This request cannot be handled by JSON API because we must simultaneously create two resources (a,b)
// a: the new clan with the leader membership, b: the leader membership with the new clan
@ApiOperation("Create a clan with correct leader, founder and clan membership")
@Operation(summary = "Create a clan with correct leader, founder and clan membership")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success with JSON { id: ?, type: 'clan'}"),
@ApiResponse(code = 400, message = "Bad Request")})
@ApiResponse(responseCode = "200", description = "Success with JSON { id: ?, type: 'clan'}"),
@ApiResponse(responseCode = "400", description = "Bad Request")})
@PostMapping(path = "/create", produces = APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_USER')")
@Transactional
Expand All @@ -69,10 +69,10 @@ public Map<String, Serializable> createClan(@RequestParam(value = "name") String
return Map.of("id", clan.getId(), "type", "clan");
}

@ApiOperation("Generate invitation link")
@Operation(summary = "Generate invitation link")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success with JSON { jwtToken: ? }"),
@ApiResponse(code = 400, message = "Bad Request")})
@ApiResponse(responseCode = "200", description = "Success with JSON { jwtToken: ? }"),
@ApiResponse(responseCode = "400", description = "Bad Request")})
@GetMapping(path = "/generateInvitationLink", produces = APPLICATION_JSON_VALUE)
public Map<String, Serializable> generateInvitationLink(
@RequestParam(value = "clanId") int clanId,
Expand All @@ -83,7 +83,7 @@ public Map<String, Serializable> generateInvitationLink(
return Map.of("jwtToken", jwtToken);
}

@ApiOperation("Check invitation link and add Member to Clan")
@Operation(summary = "Check invitation link and add Member to Clan")
@PostMapping(path = "/joinClan", produces = APPLICATION_JSON_VALUE)
@Transactional
public void joinClan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.faforever.api.data.DataController;
import com.yahoo.elide.core.dictionary.EntityDictionary;
import com.yahoo.elide.swagger.SwaggerBuilder;
import io.swagger.models.Info;
import io.swagger.models.Swagger;
import com.yahoo.elide.swagger.OpenApiBuilder;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -25,12 +25,13 @@

@Hidden
@GetMapping(value = "/elide/docs", produces = {APPLICATION_JSON_VALUE})
public ResponseEntity<String> getDocumentation() {
Info info = new Info().title("Elide JSON API").version("");
SwaggerBuilder builder = new SwaggerBuilder(entityDictionary, info);
Swagger document = builder.build()
.basePath(DataController.PATH_PREFIX);
public ResponseEntity<OpenAPI> getDocumentation() {
OpenAPI openAPI = new OpenApiBuilder(entityDictionary)
.basePath(DataController.PATH_PREFIX)
.build();

Check warning on line 31 in src/main/java/com/faforever/api/config/elide/ElideSwaggerController.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/faforever/api/config/elide/ElideSwaggerController.java#L29-L31

Added lines #L29 - L31 were not covered by tests

return ResponseEntity.ok(SwaggerBuilder.getDocument(document));
openAPI.info(new Info().title("Elide JSON API"));

Check warning on line 33 in src/main/java/com/faforever/api/config/elide/ElideSwaggerController.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/faforever/api/config/elide/ElideSwaggerController.java#L33

Added line #L33 was not covered by tests

return ResponseEntity.ok(openAPI);

Check warning on line 35 in src/main/java/com/faforever/api/config/elide/ElideSwaggerController.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/faforever/api/config/elide/ElideSwaggerController.java#L35

Added line #L35 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import com.faforever.api.error.Error;
import com.faforever.api.error.ErrorCode;
import com.google.common.io.Files;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down Expand Up @@ -41,11 +41,11 @@ public ModelAndView showValidationForm(Map<String, Object> model) {
return new ModelAndView("upload_exe_form.html");
}

@ApiOperation("Upload an exe file and override the existing one for the current version")
@Operation(summary = "Upload an exe file and override the existing one for the current version")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 500, message = "Failure")})
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "Failure")})
@RequestMapping(path = "/upload", method = RequestMethod.POST, produces = APPLICATION_JSON_UTF8_VALUE)
public void upload(@RequestParam("file") MultipartFile file,
@RequestParam("modName") String modName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.yahoo.elide.jsonapi.models.Data;
import com.yahoo.elide.jsonapi.models.JsonApiDocument;
import com.yahoo.elide.jsonapi.models.Resource;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -30,7 +30,7 @@ public class FeaturedModsController {
private final FeaturedModService featuredModService;

@RequestMapping(path = "/{modId}/files/{version}")
@ApiOperation("Lists the required files for a specific featured mod version")
@Operation(summary = "Lists the required files for a specific featured mod version")
@PreAuthorize("hasScope('" + OAuthScope._LOBBY + "')")
public JsonApiDocument getFiles(@PathVariable("modId") int modId,
@PathVariable("version") String version,
Expand All @@ -54,7 +54,7 @@ public JsonApiDocument getFiles(@PathVariable("modId") int modId,

private Function<FeaturedModFile, Resource> modFileMapper() {
return file -> new Resource("featuredModFile", String.valueOf(file.getId()),
Map.of(
null, Map.of(
"group", file.getGroup(),
"md5", file.getMd5(),
"name", file.getName(),
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/faforever/api/map/MapsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import com.faforever.api.security.OAuthScope;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
Expand Down Expand Up @@ -44,10 +44,10 @@ public ModelAndView showValidationForm(Map<String, Object> model) {
return new ModelAndView("validate_map_metadata.html");
}

@ApiOperation("Validate map name")
@Operation(summary = "Validate map name")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Information about derived names to be used in the scenario.lua"),
@ApiResponse(code = 422, message = "A list of reasons why the name is not valid.")
@ApiResponse(responseCode = "200", description = "Information about derived names to be used in the scenario.lua"),
@ApiResponse(responseCode = "422", description = "A list of reasons why the name is not valid.")
})
@RequestMapping(
path = "/validateMapName",
Expand All @@ -58,10 +58,10 @@ public MapNameValidationResponse validateMapName(@RequestParam("mapName") String
return mapService.requestMapNameValidation(mapName);
}

@ApiOperation("Validate scenario.lua")
@Operation(summary = "Validate scenario.lua")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Valid without further information"),
@ApiResponse(code = 422, message = "A list of errors in the scenario.lua")})
@ApiResponse(responseCode = "200", description = "Valid without further information"),
@ApiResponse(responseCode = "422", description = "A list of errors in the scenario.lua")})
@RequestMapping(
path = "/validateScenarioLua",
method = RequestMethod.POST,
Expand All @@ -71,11 +71,11 @@ public void validateScenarioLua(@RequestParam(name = "scenarioLua") String scena
mapService.validateScenarioLua(scenarioLua);
}

@ApiOperation(value = "Upload a map")
@Operation(summary = "Upload a map")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 500, message = "Failure")})
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "Failure")})
@RequestMapping(path = "/upload", method = RequestMethod.POST, produces = APPLICATION_JSON_UTF8_VALUE)
@PreAuthorize("hasScope('" + OAuthScope._UPLOAD_MAP + "')")
public void uploadMap(@RequestParam("file") MultipartFile file,
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/faforever/api/mod/ModsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.faforever.api.config.FafApiProperties;
import com.faforever.api.player.PlayerService;
import com.faforever.api.security.OAuthScope;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
Expand All @@ -30,11 +30,11 @@ public class ModsController {
private final ModService modService;
private final FafApiProperties fafApiProperties;

@ApiOperation("Upload a mod")
@Operation(summary = "Upload a mod")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 500, message = "Failure")})
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "Failure")})
@RequestMapping(path = "/upload", method = RequestMethod.POST, produces = APPLICATION_JSON_UTF8_VALUE)
@PreAuthorize("hasScope('" + OAuthScope._UPLOAD_MOD + "')")
public void uploadMod(
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/faforever/api/user/MeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.yahoo.elide.jsonapi.models.Data;
import com.yahoo.elide.jsonapi.models.JsonApiDocument;
import com.yahoo.elide.jsonapi.models.Resource;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import lombok.Value;
Expand All @@ -34,8 +34,8 @@ public class MeController {
private final UserSupplier userSupplier;

@RequestMapping(method = RequestMethod.GET, value = "/me")
@ApiOperation("Returns the authentication object of the current user")
@ApiResponse(code = 200, message = "Success with JsonApi compliant MeResult")
@Operation(summary = "Returns the authentication object of the current user")
@ApiResponse(responseCode = "200", description = "Success with JsonApi compliant MeResult")
@Secured("ROLE_USER")
public JsonApiDocument me() {
FafAuthenticationToken authentication = userSupplier.get();
Expand All @@ -54,6 +54,7 @@ public JsonApiDocument me() {
return new JsonApiDocument(new Data<>(
new Resource("me",
"me",
null,
Map.of(
"userId", player.getId(),
"userName", player.getLogin(),
Expand Down
Loading
Loading