question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sealed class support

See original GitHub issue

Hey, thanks for this project, so far it looks great but I am running into some limitations with sealed classes. I have a model as follows:

data class Tablet(
    val id: String,
    val something: Something,
    val apps: Map<String, App>
)

where-as app is a sealed class and while jackson 2.10.1 recognises that and converts incoming requests perfectly fine in the generated json schema App is only displayed as an empty object. Are sealed classes meant to be supported? As far as I can tell that would probably map to a oneof, right?

Edit: For reference, here is btw the PR that added auto-discovery of sealed classes: https://github.com/FasterXML/jackson-module-kotlin/pull/240

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
Wicparcommented, Dec 3, 2019

i got it to work with:

    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
    @JsonSubTypes(
            JsonSubTypes.Type(Base.A::class, name = "a"),
            JsonSubTypes.Type(Base.B::class, name = "b"),
            JsonSubTypes.Type(Base.C::class, name = "c")
    )
    sealed class Base {
        class A(val str: String) : Base()
        class B(val i: Int) : Base()
        class C(val l: Long) : Base()
    }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sealed classes | Kotlin
Sealed classes and interfaces represent restricted class hierarchies ... All direct subclasses of a sealed class are known at compile time.
Read more >
3 Sealed Classes - Java - Oracle Help Center
Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.
Read more >
Sealed Classes and Interfaces in Java 15 - Baeldung
Sealed classes are also supported by the reflection API, where two public methods have been added to the java.lang.Class: The isSealed method ...
Read more >
Kotlin: Sealed classes and Sealed Interfaces in 2022 - Medium
Among the class modalities supported by Kotlin ( open , sealed , abstract , and final ) only abstract have been allowed to...
Read more >
Support inline sealed classes : KT-27576 - YouTrack
The goal is to be able to combine the efficiency of inline value classes with the when(x) { is Subclass -> syntax and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found