-
Notifications
You must be signed in to change notification settings - Fork 304
Description
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Windows executable
Client library/SDK language
TypeScript
Describe the bug
This is to follow up the comment below:
Happening in typescript.
- OpenAPI Spec
OneOf: https://github.com/Software-Hardware-Integration-Lab/OpenAPI/blob/8e8fabe8651c268258946ca1bc4c4788d2019880/specs/SHIELD.json#L1022Behavior:
Types are generated correctly; execution time deserialization puts the Managed Privilege Device properties into additional properties instead of using the privileged device as the resultant type and putting them on the root object.
(The second item/type in the OneOf list is never deserializes, only the first time. If an object of the second type is received, its properties are put into additional properties instead of the root object as expected.)
Originally posted by @elliot-huffman in #2720
Issue Summary
Problem Area: Microsoft Kiota OpenAPI client code generator
Component: Deserialization logic for schemas using oneOf
Spec Reference: SHIELD.json#L1022 (https://github.com/Software-Hardware-Integration-Lab/OpenAPI/blob/8e8fabe8651c268258946ca1bc4c4788d2019880/specs/SHIELD.json#L1022)
Description
When generating TypeScript clients using Kiota from an OpenAPI schema that includes both direct properties and a oneOf construct, the deserialization behavior is incorrect.
The generated types appear correct.
However, at runtime, deserialization only works for the first type listed in the oneOf array.
If an object matching the second type is received, its properties are incorrectly placed into the additionalProperties map rather than being deserialized into the expected root object.
As a result, the schema-level properties are not present in the deserialized object when the second oneOf type is used.
We had opened a Microsoft Support ticket about this.
The support team routed us to the issue board here.
Support Service request number for your reference: 2509050040003673.
Expected behavior
The deserializer should correctly identify and instantiate any of the types listed in the oneOf array.
Schema-level properties should be preserved and placed on the root object regardless of which oneOf type is matched.
Actual Behavior
Only the first oneOf type is deserialized correctly.
Other types are ignored, and their properties are treated as additionalProperties.
How to reproduce
- Use Kiota to generate a TypeScript client from the provided OpenAPI spec.
- Send or receive an object matching the second type in the oneOf list.
- Observe that the deserialized object does not match the expected structure.
Open API description file
Kiota Version
1.0.0-preview.97
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
No response
Debug output
Click to expand log
```</details>
### Other information
_No response_
Metadata
Metadata
Assignees
Labels
Type
Projects
Status