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

kotlin: Update codegen templates to support struct enums #1793

Merged
merged 4 commits into from
Mar 6, 2025

Conversation

svix-mman
Copy link
Contributor

@svix-mman svix-mman commented Mar 5, 2025

The API looks like this

val sourceIn = IngestSourceIn(
    name = "name",
    uid = "uuiidd",
    config = IngestSourceInConfig.Cron(
        CronConfig(
            contentType = "ads123",
            payload = "payload",
            schedule = "* * * * *",
        )
    ),
)
// read the payload field
if (sourceIn.config is Cron) {
    // smart cast
    println(sourceIn.config.cron.payload)
}

// without any enum fields
val sourceIn = IngestSourceIn(
    name = "name",
    uid = "uuiidd",
    config = IngestSourceInConfig.Genericwebhook,
)

ref: https://github.com/svix/monorepo-private/issues/9981

@svix-mman svix-mman requested a review from a team as a code owner March 5, 2025 19:20
@svix-mman svix-mman force-pushed the mendy/kotlin-struct-enums branch from c25d8ce to 2b57fa1 Compare March 6, 2025 15:53
@svix-mman svix-mman requested a review from svix-jplatte March 6, 2025 17:02
@svix-mman svix-mman force-pushed the mendy/kotlin-struct-enums branch 2 times, most recently from 2b534d7 to b9bd5b3 Compare March 6, 2025 19:09
@svix-mman svix-mman force-pushed the mendy/kotlin-struct-enums branch from b9bd5b3 to f138137 Compare March 6, 2025 19:12
// the assertIs smart casted for us
assertEquals("* * * * *", sourceIn.config.cron.schedule)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

You should configure your editor to always write a final newline ;)

Copy link
Member

Choose a reason for hiding this comment

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

VSCode: "files.insertFinalNewline": true,

Copy link
Member

@svix-jplatte svix-jplatte left a comment

Choose a reason for hiding this comment

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

Guess I can insert that newline myself soon-ish..

@svix-jplatte svix-jplatte merged commit d29424f into main Mar 6, 2025
9 checks passed
@svix-jplatte svix-jplatte deleted the mendy/kotlin-struct-enums branch March 6, 2025 19:25
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.

2 participants