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

refactor: Replace Spray JSON with ZIO-JSON in some projects endpoints (DEV-3375) #3095

Merged

Conversation

BalduinLandolt
Copy link
Collaborator

@BalduinLandolt BalduinLandolt commented Mar 5, 2024

Pull Request Checklist

Task Description/Number

Issue Number: DEV-3375

This PR does the following things:

  • change JSON serialization for some (not yet all!) project endpoints from Spray JSON to ZIO-JSON
    (this includes adding codecs to all response objects and removing the spray stuff)
  • rename the changed response objects, removing the ADM suffix
  • add a separate internal -> external transformation for the updated response objects that does not depend on a trait that is polluted with spray logic
  • update the tests accordingly (some of them used the spray codecs)

PR Type

  • build/chore: maintenance tasks (no production code change)
  • docs: documentation changes (no production code change)
  • feat: represents new features
  • fix: represents bug fixes
  • perf: performance improvements
  • refactor: represents production code refactoring
  • test: adding or refactoring tests (no production code change)

Basic requirements for bug fixes and features

  • Tests for the changes have been added
  • Docs have been added / updated

Does this PR introduce a breaking change?

  • Yes

Does this PR change client-test-data?

  • Yes

Copy link

linear bot commented Mar 5, 2024

@BalduinLandolt BalduinLandolt self-assigned this Mar 5, 2024
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 41 lines in your changes are missing coverage. Please review.

Project coverage is 12.89%. Comparing base (eac5751) to head (f0be542).
Report is 110 commits behind head on main.

Files Patch % Lines
...ice/admin/api/service/PermissionsRestService.scala 0.00% 11 Missing ⚠️
.../scala/org/knora/webapi/routing/RouteUtilADM.scala 0.00% 7 Missing ⚠️
...pi/slice/admin/api/service/GroupsRestService.scala 0.00% 7 Missing ⚠️
...ice/admin/api/service/ProjectsADMRestService.scala 0.00% 5 Missing ⚠️
...api/slice/admin/api/service/UsersRestService.scala 0.00% 5 Missing ⚠️
...webapi/responders/admin/ProjectsResponderADM.scala 0.00% 3 Missing ⚠️
...slice/admin/domain/service/ProjectADMService.scala 0.00% 2 Missing ⚠️
...esponder/resourcemessages/ResourceMessagesV2.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3095      +/-   ##
==========================================
+ Coverage   11.74%   12.89%   +1.15%     
==========================================
  Files         246      260      +14     
  Lines       22907    22385     -522     
==========================================
+ Hits         2690     2887     +197     
+ Misses      20217    19498     -719     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BalduinLandolt BalduinLandolt marked this pull request as ready for review March 5, 2024 16:59
Copy link
Collaborator

@mpro7 mpro7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please check my questions/suggestions:

@@ -90,6 +89,24 @@ object RouteUtilADM {
}
}

def transformResponseIntoExternalFormat(
response: AdminResponse,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: To me the AdminResponse marker trait feels like a bit to much code for not a real benefit.

Seeing that this function always returns the response as the same type and even unchanged if it is not doing anything with it I am wondering if we really need a marker trait AdminResponse. The underlying function could be generic and accept all inputs:

def transformResponseIntoExternalFormat[A](response: A): Task[A]

wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented it like this to follow the existing pattern (and because at first it seemed hard to get SipiIT to work without a trait. But in the end this really turned out useless, so I'm happy to remove it.

.description("Returns the project's restricted view settings identified by the shortcode.")

val getAdminProjectsByProjectShortnameRestrictedViewSettings = baseEndpoints.publicEndpoint.get
.in(projectsByShortname / restrictedViewSettings)
.out(sprayJsonBody[ProjectRestrictedViewSettingsGetResponseADM])
.out(zioJsonBody[ProjectRestrictedViewSettingsGetResponseADM])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Bye bye spray, hello zio. Good stuff, thanks.

@BalduinLandolt BalduinLandolt enabled auto-merge (squash) March 6, 2024 14:32
@BalduinLandolt BalduinLandolt merged commit 70ea9ba into main Mar 6, 2024
13 checks passed
@BalduinLandolt BalduinLandolt deleted the feature/dev-3375-introduce-zio-json-in-projects-routes branch March 6, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants