microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
3.02k stars 210 forks source link

[TS] Enum default value deserialization #4216

Closed lroos closed 9 months ago

lroos commented 9 months ago

I have an OpenAPI type definition geography with an enum field type that has a default value States:

"geography": {
  "type": "object",
  "properties": {
    "type": {
      "default": "States",
      "enum": ["States","Counties", ...],

I see a build error in the generated TypeScript client model code line in /client/models/index.ts in the method deserializeIntoGeography ('Geography_type' only refers to a type, but is being used as a value):

"type": n => { geography.type = n.getEnumValue<Geography_type>(Geography_typeObject) ?? Geography_type.States; },

and I am able to fix it by changing it to:

"type": n => { geography.type = n.getEnumValue<Geography_type>(Geography_typeObject) ?? Geography_typeObject.States; },

using Kiota dotnet tool version 1.11.1+86b3a623dc3fb6b55fed6a49519ec837f0fbc02c

lroos commented 9 months ago

FYI traced this to a regression in v1.9.1 #3862