$ref fragments are expected to be full openapi documents
- 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
Kiota will throw an error if a referenced fragment isn't a full openapi document
```
fail: Kiota.Builder.KiotaBuilder[0]
OpenAPI error: (null) - [File: fragment.json] Version node not found.
```
### Expected behavior
fragments do not need to be full openapi documents and can be just a fragment of it
### How to reproduce
`dotnet kiota generate -l CSharp -d `
### Open API description file
```jsonc
{
"openapi": "3.0.1",
"info": {
"title": "Test API",
"version": "v1"
},
"paths": {
"/foo": {
"$ref": "fragment.json#/get"
}
}
}
```
**fragment.json**
```jsonc
{
"get": {
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
}
}
}
}
}
```
### Kiota Version
1.29.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
Research direction
Start with the `dotnet kiota generate -l CSharp -d ` entry point and reproduce the failure using the OpenAPI description and `fragment.json` shown in the issue. Trace external `$ref` handling to see why `fragment.json#/get` is treated as a complete document; done means the sample generates successfully without the Version node error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100