Skip to content
Open
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.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ val circeV = "0.14.14"
val circeGenericExtrasV = "0.14.4"
val circeYamlV = "0.15.2" // 0.15.3 drops Scala 2.12
val jwtCirceV = "11.0.2"
val jacksonV = "2.18.2" // 2.18.3+ breaks ContentTypesSchemas.schemaForPlain
val jacksonV = "2.18.4"
val catsV = "2.13.0"
val catsEffectV = "3.5.7"
val everitSchemaV = "1.14.5"
Expand Down
4 changes: 2 additions & 2 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ description: Stay informed with detailed changelogs covering new features, impro
}
}
```
* [#8352](https://github.com/TouK/nussknacker/pull/8352) Updated dependencies:
* [#8352](https://github.com/TouK/nussknacker/pull/8352)[#8449](https://github.com/TouK/nussknacker/pull/8449) Updated dependencies:
* Caffeine Cache 3.1.8 -> 3.2.1
* Cats Effect 3.5.4 -> 3.5.7
* Cats 2.12.0 -> 2.13.0
* Circe 0.14.10 -> 0.14.14
* HikariCP 6.2.1 -> 6.3.1
* Jackson 2.17.2 -> 2.18.2
* Jackson 2.17.2 -> 2.18.4
* Netty 4.1.119.Final -> 4.1.123.Final
* PostgreSQL JDBC driver 42.7.4 -> 42.7.7
* sttp 3.9.8 -> 3.11.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ object ContentTypes extends Enumeration {
}

object ContentTypesSchemas {
val schemaForJson: OpenAPIJsonSchema = OpenAPIJsonSchema("{}")
// note: "" deserializes to com.fasterxml.jackson.databind.node.MissingNode,
// which causes NPE when using Jackson 2.18.3+, because from this version on it decodes to null
val schemaForPlain: OpenAPIJsonSchema = OpenAPIJsonSchema("")
val schemaForJson: OpenAPIJsonSchema = OpenAPIJsonSchema("{}")
Copy link
Copy Markdown
Contributor

@lciolecki lciolecki Aug 4, 2025

Choose a reason for hiding this comment

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

Hmm, do we even need these two schemas?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Unfortunately, yes:

class UniversalSchemaSupportDispatcher private (kafkaConfig: KafkaConfig) {
...
  def forParsedSchema(parsedSchema: ParsedSchema): UniversalSchemaSupport = parsedSchema match {
    // For ad hoc tests we want to present the user with json editor when topic has no schema and content type Json was selected
    case ContentTypesSchemas.schemaForJson => NoSchemaJsonSupport
    case _                                 => forSchemaType(parsedSchema.schemaType())
  }

val schemaForPlain: OpenAPIJsonSchema = OpenAPIJsonSchema("true")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you sure about this? :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, it's that or some heavier refactoring. true after parsing results in the same schema: {}. An alternative would be to use {} ({} with some whitespace around) with custom equals method for OpenAPIJsonSchema.

I mention custom equals because OpenAPIJsonSchema is a fake case class - default Scala's equals for case classes doesn't work there, it's implemented like this:

  test("boxes are equal") {
    class BoxParent {
      override def equals(obj: Any): Boolean = true
      override def hashCode(): Int = 0
    }

    case class Box(v: String) extends BoxParent

    // this equality is true in Scala, but not in real world
    Box("socks") shouldBe Box("gold")
  }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pl.touk.nussknacker.engine.schemedkafka.schemaregistry

import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

class ContentTypesSchemasTest extends AnyFunSuite with Matchers {

test("schemaForJson is distinct from schemaForPlain") {
ContentTypesSchemas.schemaForJson shouldNot be(ContentTypesSchemas.schemaForPlain)
}

}
Loading