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

Support field renaming within parent classes/interfaces #1272

Open
benkuly opened this issue Dec 30, 2020 · 2 comments
Open

Support field renaming within parent classes/interfaces #1272

benkuly opened this issue Dec 30, 2020 · 2 comments

Comments

@benkuly
Copy link

benkuly commented Dec 30, 2020

What is your use-case and why do you need this feature?
Currently, one need to rename every implemented field of a parent class/interface:

interface Project {
    val name: String
    val originalTime: Long
}

@Serializable
class OwnedProject(
    @SerialName("custom_name")
    override val name: String, 
    @SerialName("original_t")
    override val originalTime: String
) : Project

@Serializable
class OtherProject(
    @SerialName("custom_name")
    override val name: String, 
    @SerialName("original_t")
    override val originalTime: String,
    val other: String
) : Project

Describe the solution you'd like
It should be able to use @SerialName on parent fields:

interface Project {
    @SerialName("custom_name")
    val name: String
    @SerialName("original_t")
    val originalTime: Long
}

@Serializable
class OwnedProject(
    override val name: String, 
    override val originalTime: String
) : Project

@Serializable
class OtherProject(
    override val name: String, 
    override val originalTime: String,
    val other: String
) : Project
@NoZomIBK
Copy link

NoZomIBK commented Feb 3, 2023

I think other Annotations like Transient and Required etc. should be inherited as well

@sandwwraith
Copy link
Member

Related comment: #1950 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants