-
Notifications
You must be signed in to change notification settings - Fork 214
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
[TS] Regression in handling enums #4199
Comments
I'm trying to understand "what to fix" here and I'm a bit confused.
Do we want to encode Enums closer to classes or should we enable them to be used more like primitives? |
Thanks for raising this @andreaTP I believe due to the |
Thanks for the feedback @andrueastman ! Either:
|
Taking a deeper look at TS abstractions, it looks like like Parsable is an empty interface. Which means the Parsable constraint assumed doesn't hold here. So, we may use the second option here, but this may be different for other languages. @andreaTP Any chance you can share the link to the original openApi description for the client in the PR? I'd like to compare behaviors in different languages first. Unfortunately, when I take a look at the GO client generated, it seems to suggest the path returns a collection and not a single value. |
You are correct, the original OpenAPI definition uses a collection, I removed it as the problem can be reproduced. This is the original description for both Go and Typescript |
Taking a look across languages, looks like enums should ideally be handled separetely from either objects or primitives. The TS abstractions is missing the Dotnet seems to have mapped enums to primitives(I suspect adding the methods later on would have been a breaking change. Created issue for it at microsoft/kiota-dotnet#199) As this change is not breaking in TS, we should probably update the requestAdapter interface so that it includes these methods, and update the generator for enum handling, then have the relevant method call the getEnumValue/getCollectionOfEnumValues methods on the received response. |
Is this work already scheduled on your side? |
Hey everyone! 👋 |
Thanks for the wrap-up @baywet , appreciated, I'm going to have a pretty busy schedule in the next weeks, so let's see who comes first to this one. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Can we set this to "never-stale"? We can close when completed. |
The following OpenAPI description:
Generates invalid code:
where
createRuleTypeFromDiscriminatorValue
is not defined in any of the generated files.Found here.
The text was updated successfully, but these errors were encountered: