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
How to remove type information with polymorphic output? #175
Comments
I was just able to rename the @Serializable
data class Group(@SerialName("group") override val name: String) : VariableBase() This gives the following output and brings me one step closer to the solution. variables:
- type: "Variable"
name: "myVar"
value: "myValue"
readonly: false
- type: "Group"
group: "myFirstGroup"
- type: "Group"
group: "mySecondGroup"
- type: "Group"
group: "myThirdGroup" Now I just need to get rid of the |
The only issue I see at this moment is that this can be used to serialise. But it will be hard to deserialise when the type is not known. Is it ok when that would be a known limitation of |
Hi @johanvergeer, in this case, I'd suggest creating a custom serializer for the On serialization, it could check the type of the input object and call directly into the derived class' serializer to output the value without any decoration (eg. a If you also need deserialization, it could take the (I'm hesitant to add support for |
Hi @johanvergeer, did that work for your situation? |
Hi @charleskorn I'm pretty busy at the moment at work, so I haven't been able to get it working yet. (Also because I'm no expert so I need some figuring out 😉) I will give it a try later this week. |
Hi @charleskorn That works like a charm. Thanks for your help. 😄 |
I'm working on a dsl for Azure DevOps YAML Pipelines and they have a block called
variables
that can contain a few types.I've been working on this for a while now and by now I have been able to create a list of
Variable
This will generate the following output:
So how would I be able to create the list that is required to create an Azure DevOps YAML Pipeline variables block?
I guess it might be an idea to add a
PolymorphismStyle.None
to prevent a type output. I'll create a PR if you think that is a good idea.The text was updated successfully, but these errors were encountered: