microsoft / microsoft/kiota

Trying to generate Kiota anyOf with (int and string) Kiota has been changing this to number and string validations are failing

Open
#6,801 1 comment 1 reaction 0 assignees View on GitHub
type:bug TypeScript
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?

Mac executable

### Client library/SDK language

TypeScript

### Describe the bug

while generating a kiota typescript sdk using the following schema

ssh_key_identifier:
in: path
name: ssh_key_identifier
required: true
description: Either the ID or the fingerprint of an existing SSH key.
schema:
anyOf:
- $ref: '#/components/schemas/ssh_key_id' (which has a number here)
- $ref: '#/components/schemas/ssh_key_fingerprint' (which has string here)
example :123456

Kiota generating number by default and i cannot access the queries which are needed to be used for string(fingerprint).

### Expected behavior

expected to be generated something like;;
ssh_key_identifier(body : number | string)
but generated only
ssh_key_identifier(body: number)

### How to reproduce

ssh_key_identifier:
in: path
name: ssh_key_identifier
required: true
description: Either the ID or the fingerprint of an existing SSH key.
schema:
anyOf:
- $ref: '#/components/schemas/ssh_key_id' (which has a number here)
- $ref: '#/components/schemas/ssh_key_fingerprint' (which has string here)
example :123456

ssh_key_id:
type: integer
description: >-
A unique identification number for this key. Can be used to embed a
specific SSH key into a Droplet.
readOnly: true
example: 512189

ssh_key_fingerprint:
type: string
description: >-
A unique identifier that differentiates this key from other keys using
a format that SSH recognizes. The fingerprint is created when the key is
added to your account.
readOnly: true
example: 3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa

### Open API description file

_No response_

### Kiota Version

1.27.0

### 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
```

```

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided OpenAPI schema and Kiota 1.27.0, targeting TypeScript generation. Trace how the anyOf path parameter is represented and compare the generated signature with the expected number | string form; done means both numeric IDs and string fingerprints are available through the generated queries.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.