-
Notifications
You must be signed in to change notification settings - Fork 34
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
Handling string enum OnRead #510
Comments
Hi @ShiiniiDev This is one of the very few design assumptions that kiota has had since its genesis. Enums are serialized as strings (or array of strings depending on the scenario) Do you have the ability to turn on string serialization for enums in your API? |
Hey @baywet
On my API point of view I've this setup
Which will respond, as I expect
To provide more context the DTO looks like
But when Kiota receives the message Thanks for your time |
Thank you for the additional information. Can you please share the OpenAPI description section for the enum? |
Hoping it will help |
Thank you for the additional information. Yes, that effectively maps to a GetStringValue from System.Text.Json
So what I believe is happening is that API actually returns numerical values for some reason. Can you double check the returned payload from the API please? |
@baywet Thanks for this message you pointed it out my mistake, because JsonParseNode wasnt called in my case. I wanted to get the API error message, in order to throw/fail the test in proper way So I was using Text.Json instead of Json.Net
|
Using Kiota I got generated
On writing it works well, it will be written "myEnum": "A"
On reading, it fails
The _converterOptions is set to AllowInteger, so it throws
Here my Http setup
I dont know if I'm able to inject/use a specific json serializer like JsonNet, or custom something.. I didnt find anything relevant to help me.
Or if I've missed a step/a detail
The text was updated successfully, but these errors were encountered: