[C#] Single-element allOf wrapping an inline object silently drops the property and prunes its referenced schema
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 333
- Avg merge
- 16h 29m
- Merged PRs (30d)
- 116
Description
### 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
When a component schema is a **single-element `allOf`** that wraps an inline object, and that inline object's property value is a `$ref` to another schema, Kiota generates the wrapper as an empty class (only `AdditionalData`, an empty `GetFieldDeserializers()`, no property) and does not emit the referenced schema at all. No warning or error appears in `.kiota.log`.
The affected property can never be serialized or deserialized by the generated client, and there is no diagnostic to indicate anything was dropped, resulting in silent wire-level data loss. Kiota appears to treat the single-element `allOf` as a polymorphic/discriminator base and discards the orphaned inline object and, transitively, the schema referenced by its property.
## Impact
Silent data loss on a typed client. Across a real ISO 20022 (pain.001) spec this pruned 8 such `*Choice` schemas, each losing its payload and its referenced generic-identification model.
## Related (not duplicates)
- #6778 (open): similar symptom but requires a `oneOf` wrapper around a multi-element `allOf` with a base `$ref`
- #5014 (closed, PR #5123): single-element `allOf` of a **bare `$ref`** (inheritance), not an inline object with a `$ref` property
- #4346 / #4074 (closed): multi-element `allOf` with inline props sibling to a `$ref`; referenced schema still emitted
### Expected behavior
## Given
- The minimal OpenAPI specification in the next section
## Expected
- `AccountIdentification4Choice` has a typed `Other` property of type `GenericAccountIdentification1`, wired into `GetFieldDeserializers()`/`Serialize()`
- `GenericAccountIdentification1` is generated as its own model class
## Actual
- `AccountIdentification4Choice` is an empty class (only `AdditionalData`, empty `GetFieldDeserializers()`, no `Other`)
- `GenericAccountIdentification1` is not generated at all
- No warning/error in `.kiota.log`
### How to reproduce
## Minimal reproduction
```yaml
openapi: 3.0.3
info: { title: repro, version: 1.0.0 }
paths:
/x:
get:
responses:
'200':
description: ok
content:
application/json:
schema:
$ref: '#/components/schemas/AccountIdentification4Choice'
components:
schemas:
AccountIdentification4Choice:
type: object
allOf:
- type: object
required: [other]
properties:
other:
$ref: '#/components/schemas/GenericAccountIdentification1'
GenericAccountIdentification1:
type: object
required: [identification]
properties:
identification:
type: string
```
Command: `kiota generate -l CSharp -d repro.yaml -o ./out -c ApiClient -n Repro.Client`
(also reproduced with(out) `--exclude-backward-compatible`, with `--structured-mime-types application/json`, and `--disable-validation-rules all`.)
### Open API description file
```yaml
openapi: 3.0.3
info: { title: repro, version: 1.0.0 }
paths:
/x:
get:
responses:
'200':
description: ok
content:
application/json:
schema:
$ref: '#/components/schemas/AccountIdentification4Choice'
components:
schemas:
AccountIdentification4Choice:
type: object
allOf:
- type: object
required: [other]
properties:
other:
$ref: '#/components/schemas/GenericAccountIdentification1'
GenericAccountIdentification1:
type: object
required: [identification]
properties:
identification:
type: string
```
### Kiota Version
1.32.1
### Latest Kiota version known to work for scenario above?(Not required)
_No response_
### Known Workarounds
A sibling schema written as a direct object (no `allOf`) with the identical property generates correctly, isolating the cause to the single-element-`allOf` wrapper and not the `$ref` property or the referenced schema.
### Configuration
- OS: MacOS Tahoe
- Architecture: ARM64
### Debug output
_No response_
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal OpenAPI specification with the documented `kiota generate -l CSharp -d repro.yaml -o ./out -c ApiClient -n Repro.Client` command and compare the generated models with the expected output. Trace handling of the single-element `allOf` containing an inline object, then add coverage showing that `AccountIdentification4Choice` includes `Other` and that `GenericAccountIdentification1` is generated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100