You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is extremely unsafe and it works only because there is a "hidden" contract with the generator to emit the specific forValue method on the enum class.
My first reaction would be to make it more similar to a normal "class", and extend the API of ValuedEnum to cover the deserialization explicitly.
Please note that this is going to be a breaking API change for abstractions and I hope we can fix it before GA.
Do you have any prior art on the subject?
Any consideration?
The text was updated successfully, but these errors were encountered:
The reason why we had to resolve to reflections are because it's a static method, so it can't be part of the ValuedEnum interface like getValue, because the return type varies (based on the enum type, but maybe we could get around that with generics).
And this is a static method because we don't have an instance yet.
And this is a static method because we don't have an instance yet.
Right, but this is a design choice, we can make it a class method and have a static way of retrieving an instance ( similar to what createFromDiscriminatorValue does.
Alternatively, we can add an interface at the parent level, but this means that no enum can be serialized without the scope of an object which seems to be a limitation.
I think the first option would probably work better here. In fact this is what we're doing in Go I think the history here was that I implemented it in dotnet, patched it in Java, later on implemented it in Go, and never went back to update java 🤦♂️
kiota-java/components/serialization/json/src/main/java/com/microsoft/kiota/serialization/JsonParseNode.java
Line 309 in 033afd1
This is extremely unsafe and it works only because there is a "hidden" contract with the generator to emit the specific
forValue
method on the enum class.My first reaction would be to make it more similar to a normal "class", and extend the API of
ValuedEnum
to cover the deserialization explicitly.Please note that this is going to be a breaking API change for abstractions and I hope we can fix it before GA.
Do you have any prior art on the subject?
Any consideration?
The text was updated successfully, but these errors were encountered: