Skip to content

Weakly typed path parameters and nullable response properties (C#) #2594

@kimbirkelund

Description

@kimbirkelund

I'm trying to use Kiota to generate a client for an internal API, but I'm running into a few issues that I can't seem to find documentation for - either in the actual documentation or previous issues, but I apologize if I'm just not looking hard enough :)

I'm using the following spec snippet for the issues below but it happens in samples as well:

"/foo/{fooId}": {
  "get": {
    "parameters": [
      {
        "name": "fooId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer",
          "format": "int32"
        }
      }
    ],
    "responses": {
      "200": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FooResponse"
            }}}}}}}
"FooResponse": {
  "required": [
    "fooId"
  ],
  "type": "object",
  "properties": {
    "fooId": {
      "type": "integer",
      "format": "int32"
    }
  },
  "additionalProperties": false
}

In the generated client I see the following issues:

  1. In the request builder the indexer parameter is string position although the spec clearly states that it is an integer named fooId.

  2. The generated WithFooItemRequestBuilder.GetAsync returns Task<FooResponse?> even though spec says it always returns a response. I could understand if this was to map 404 to null, but this does not appear to be the case.

  3. In the FooResponse model the property for fooId, which in the spec is a required integer, is also nullable and this appears to be the case for all properties.

From what I've read Kiota is intended to generate easily usable clients from the consumer point of view so consistency is more important than tailoring the client to something the producer would like.

I'm fully on board with this perspective, but these issues, to me, does not align with that. So I'm curious as to why these choices were made.

Metadata

Metadata

Assignees

Labels

WIPenhancementNew feature or requestgeneratorIssues or improvements relater to generation capabilities.

Type

No type

Projects

Status

Done ✔️

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions