diff --git a/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/scenariodetails/ScenarioWithDetails.scala b/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/scenariodetails/ScenarioWithDetails.scala index 570c29020b0..d884e8feac9 100644 --- a/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/scenariodetails/ScenarioWithDetails.scala +++ b/designer/restmodel/src/main/scala/pl/touk/nussknacker/restmodel/scenariodetails/ScenarioWithDetails.scala @@ -77,13 +77,19 @@ object ScenarioWithDetails { import io.circe.generic.semiauto._ + // TODO: We remove null values from json to make response payload lighter. + // The target solution would be to introduce pagination to the /api/processes endpoint. implicit val encoder: Encoder[ScenarioWithDetails] = - deriveEncoder[ScenarioWithDetails] - .contramap[ScenarioWithDetails](_.copy(processId = None)) + deepDropNulls( + deriveEncoder[ScenarioWithDetails] + .contramap[ScenarioWithDetails](_.copy(processId = None)) + ) implicit val decoder: Decoder[ScenarioWithDetails] = deriveDecoder[ScenarioWithDetails] + private def deepDropNulls[A](encoder: Encoder[A]): Encoder[A] = encoder.mapJson(_.deepDropNullValues) + } // This class is to enforce consistency of fields between CreateScenarioCommand and ScenarioWithDetails. diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ProcessesResourcesSpec.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ProcessesResourcesSpec.scala index c19505bf084..349fd4fe18c 100644 --- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ProcessesResourcesSpec.scala +++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ProcessesResourcesSpec.scala @@ -130,7 +130,7 @@ class ProcessesResourcesSpec } test("/api/processes should return lighter details without ProcessAction's additional fields") { - createDeployedWithCustomActionScenario(processName, category = Category1) + createDeployedScenario(processName, category = Category1) Get(s"/api/processes") ~> withReaderUser() ~> applicationRoute ~> check { status shouldEqual StatusCodes.OK val loadedProcess = responseAs[List[ScenarioWithDetails]] diff --git a/docs/Changelog.md b/docs/Changelog.md index 4a02a97a4eb..617f45f9f26 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -34,7 +34,7 @@ this fixes issue with unexpected low scale when performing division on BigDecimals which were created in such conversion. * [#7368](https://github.com/TouK/nussknacker/pull/7368) Component rename: `periodic` to `sample-generator` * [#7379](https://github.com/TouK/nussknacker/pull/7379) Removed CustomAction mechanism. -* [#7354](https://github.com/TouK/nussknacker/pull/7354) Reduce response payload size when fetching scenarios for scenarios tab by removing unused fields. +* [#7354](https://github.com/TouK/nussknacker/pull/7354) Reduce response payload size when fetching scenarios for scenarios tab by removing unused fields and `null` attributes. ## 1.18