Skip to content

Commit

Permalink
fix: Make hal+json responses just json (#2773)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar authored Dec 12, 2024
1 parent a84160a commit a30c7cd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import io.tolgee.security.authorization.RequiresProjectPermissions
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.hateoas.MediaTypes
import org.springframework.hateoas.PagedModel
import org.springframework.web.bind.annotation.CrossOrigin
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -46,7 +45,7 @@ class ProjectActivityController(
private val modifiedEntityModelAssembler: ModifiedEntityModelAssembler,
) {
@Operation(summary = "Get project activity")
@GetMapping("", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("")
@RequiresProjectPermissions([ Scope.ACTIVITY_VIEW ])
@AllowApiAccess
fun getActivity(
Expand All @@ -57,7 +56,7 @@ class ProjectActivityController(
}

@Operation(summary = "Get one revision data")
@GetMapping("/revisions/{revisionId}", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("/revisions/{revisionId}")
@RequiresProjectPermissions([Scope.ACTIVITY_VIEW])
@AllowApiAccess
fun getSingleRevision(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import io.tolgee.service.language.LanguageService
import io.tolgee.service.project.LanguageStatsService
import io.tolgee.service.project.ProjectService
import io.tolgee.service.project.ProjectStatsService
import org.springframework.hateoas.MediaTypes
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.CrossOrigin
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -38,7 +38,7 @@ class ProjectStatsController(
private val languageService: LanguageService,
) {
@Operation(summary = "Get project stats")
@GetMapping("", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE])
@UseDefaultPermissions
@AllowApiAccess
fun getProjectStats(): ProjectStatsModel {
Expand Down Expand Up @@ -73,7 +73,7 @@ class ProjectStatsController(
}

@Operation(summary = "Get project daily amount of events")
@GetMapping("/daily-activity", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("/daily-activity")
@RequiresProjectPermissions([ Scope.ACTIVITY_VIEW ])
@AllowApiAccess
fun getProjectDailyActivity(): Map<LocalDate, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Sort
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.data.web.SortDefault
import org.springframework.hateoas.MediaTypes
import org.springframework.hateoas.PagedModel
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
Expand Down Expand Up @@ -148,7 +147,7 @@ class OrganizationController(
return OrganizationView.of(organization, roleType).toModel()
}

@GetMapping("", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("")
@Operation(
summary = "Get all permitted organizations",
description = "Returns all organizations, which is current user allowed to view",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.data.web.SortDefault
import org.springframework.hateoas.MediaTypes
import org.springframework.hateoas.PagedModel
import org.springframework.web.bind.annotation.CrossOrigin
import org.springframework.web.bind.annotation.GetMapping
Expand Down Expand Up @@ -81,7 +80,7 @@ class OrganizationProjectController(
"Returns all projects (including statistics)" +
" where current user has any permission (except none)",
)
@GetMapping("/{organizationId:[0-9]+}/projects-with-stats", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("/{organizationId:[0-9]+}/projects-with-stats")
@UseDefaultPermissions
fun getAllWithStatistics(
@ParameterObject pageable: Pageable,
Expand All @@ -98,7 +97,7 @@ class OrganizationProjectController(
"Returns all projects (including statistics) " +
"where current user has any permission (except none)",
)
@GetMapping("/{slug:.*[a-z].*}/projects-with-stats", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("/{slug:.*[a-z].*}/projects-with-stats")
@UseDefaultPermissions
fun getAllWithStatistics(
@ParameterObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import jakarta.validation.Valid
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.hateoas.MediaTypes
import org.springframework.hateoas.PagedModel
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
Expand Down Expand Up @@ -111,7 +110,7 @@ class ProjectsController(
}

@Operation(summary = "Get all permitted", description = "Returns all projects where current user has any permission")
@GetMapping("", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("")
@IsGlobalRoute
@AllowApiAccess(tokenType = AuthTokenType.ONLY_PAT)
@OpenApiOrderExtension(3)
Expand Down Expand Up @@ -157,7 +156,7 @@ class ProjectsController(
summary = "Get all with stats",
description = "Returns all projects (including statistics) where current user has any permission",
)
@GetMapping("/with-stats", produces = [MediaTypes.HAL_JSON_VALUE])
@GetMapping("/with-stats")
@IsGlobalRoute
fun getAllWithStatistics(
@ParameterObject pageable: Pageable,
Expand Down

0 comments on commit a30c7cd

Please sign in to comment.