microsoft / microsoft/kiota

Kiota warns that format:uri is not supported in headers

Open
#4,227 4 comments 2 reactions 0 assignees View on GitHub
generator help wanted type:bug
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

We use `"fornat": "uri"` to describe the HTTP `Location` header in our OpenAPI file, for example:

```json
{
"responses": {
"201": {
"headers": {
"Location": {
"required": true,
"schema": {
"type": "string",
"format": "uri"
}
}
}
}
}
}
```

This triggers the following warning when running the Kiota command-line tool:

```
OpenAPI warning : #/paths/~1api~1tags/post/responses/201/headers/Location/schema - The format uri is not supported by Kiota and the string type will be used.
```

Headers are exposed by `HeadersInspectionHandlerOption`, which contains the following property:

```c#
public RequestHeaders ResponseHeaders { get; private set; } = new RequestHeaders();
```

`RequestHeaders` (note the name mismatch: _response_ headers are stored in the _request_ headers object, but that's beside the point) implements `IDictionary>`, so header values are always exposed as strings. This makes me wonder whether this warning should be emitted. The warning states it will use strings instead, but isn't that _always_ the expected outcome for header values?

I'd rather not disable all warnings using `--log-level Error` when running Kiota, but without that, these show up as annoying warnings in the IDE (after running Kiota from an `Exec` task in the project file).

Would it make sense to suppress this warning for HTTP headers?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the warning with the OpenAPI file and the Kiota command-line tool, then inspect HeadersInspectionHandlerOption and its RequestHeaders property. Confirm whether format: uri warnings are emitted for HTTP headers and make the warning behavior match the intended treatment of string-valued headers.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.