Problem generating model(s) when schema has type: object
with oneOf
with single ref
#5808
Labels
Milestone
type: object
with oneOf
with single ref
#5808
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Nuget tool
Client library/SDK language
Csharp
Describe the bug
We came across this when we were using Kiota to generate our C# client-code against a contract which was work in progress.
In the contract we are using we have several
oneOf
hierarchies and in one case there was a hierarchy where there was only a single ref underoneOf
but the schema hadtype: object
set. If thetype: object
is set, the contract does not generate the expected models.I have a repository with the generated clients and example schemas which reproduce the issue available at https://github.com/vipentti/kiota-type-object-one-of-issue
Expected behavior
Kiota generates code for both schemas similarly (with or without
type: object
) because if thetype: object
is present with multipleoneOf
refs, code is generated as expected.How to reproduce
I have a repository with the generated clients and example schemas which reproduce the issue available at https://github.com/vipentti/kiota-type-object-one-of-issue
Open API description file
https://github.com/vipentti/kiota-type-object-one-of-issue/blob/main/DiscriminatorProblemSampleSimple.yaml
Kiota Version
1.20.0+81bdb1bf13383a749f794d47926d09733d2d7be1
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
Removing the
type: object
if there is only oneoneOf
seems to work, unfortunately that may not be possible if the schema is also generated by some tool and/or provided by 3rd parties.Configuration
Debug output
Click to expand log
```info: Kiota.Builder.KiotaBuilder[0]
Cleaning output directory <repo_path>\kiota-type-object-one-of-issue.\Generated\Simple\CSharp
dbug: Kiota.Builder.KiotaBuilder[0]
kiota version 1.20.0
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 1 - reading the stream - took 00:00:00.0050763
dbug: Kiota.Builder.KiotaBuilder[0]
step 2 - parsing the document - took 00:00:00.0679186
dbug: Kiota.Builder.KiotaBuilder[0]
step 3 - updating generation configuration from kiota extension - took 00:00:00.0000607
dbug: Kiota.Builder.KiotaBuilder[0]
step 4 - filtering API paths with patterns - took 00:00:00.0029692
info: Kiota.Builder.KiotaBuilder[0]
Client root URL set to https://mytodos.doesnotexist
dbug: Kiota.Builder.KiotaBuilder[0]
step 5 - checking whether the output should be updated - took 00:00:00.0074799
dbug: Kiota.Builder.KiotaBuilder[0]
step 6 - create uri space - took 00:00:00.0023193
dbug: Kiota.Builder.KiotaBuilder[0]
InitializeInheritanceIndex 00:00:00.0021671
warn: Kiota.Builder.KiotaBuilder[0]
Discriminator Component1 is not inherited from ExampleWithSingleOneOfWithTypeObject.
dbug: Kiota.Builder.KiotaBuilder[0]
CreateRequestBuilderClass 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
MapTypeDefinitions 00:00:00.0034938
info: Kiota.Builder.KiotaBuilder[0]
Removing unused model Component1 as it is not referenced by the client API surface
dbug: Kiota.Builder.KiotaBuilder[0]
TrimInheritedModels 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
CleanUpInternalState 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
step 7 - create source model - took 00:00:00.0405963
dbug: Kiota.Builder.KiotaBuilder[0]
14ms: Language refinement applied
dbug: Kiota.Builder.KiotaBuilder[0]
step 8 - refine by language - took 00:00:00.0147122
dbug: Kiota.Builder.KiotaBuilder[0]
step 9 - writing files - took 00:00:00.0188196
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 10 - writing lock file - took 00:00:00.0083907
Generation completed successfully
Client base url set to https://mytodos.doesnotexist
dbug: Kiota.Builder.KiotaBuilder[0]
Api manifest path: <repo_path>\kiota-type-object-one-of-issue\apimanifest.json
Hint: use the info command to get the list of dependencies you need to add to your project.
Example: kiota info -d "<repo_path>\kiota-type-object-one-of-issue.\DiscriminatorProblemSampleSimple.yaml" -l CSharp
Hint: use the --include-path and --exclude-path options with glob patterns to filter the paths generated.
Example: kiota generate --include-path "**/foo" -d "<repo_path>\kiota-type-object-one-of-issue.\DiscriminatorProblemSampleSimple.yaml"
The text was updated successfully, but these errors were encountered: