microsoft/kiota

Stream response for HEAD endpoint

Open

#4245 aperta il 27 feb 2024

Vedi su GitHub
 (5 commenti) (0 reazioni) (0 assegnatari)C# (326 fork)auto 404
generatorhelp wantedtype:bug

Metriche repository

Star
 (3783 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

When a HEAD endpoint contains only responses without a body (which should always be the case), Kiota generates Task<Stream?> as the response type. Is that intentional? I would have expected the return type to be Task.

Repro steps:

{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenApiTests",
    "version": "1.0"
  },
  "paths": {
    "/countries": {
      "head": {
        "tags": [
          "countries"
        ],
        "operationId": "headCountryCollection",
        "responses": {
          "200": {
            "headers": {
              "ETag": {
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "Content-Length": {
                "required": true,
                "schema": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "304": {
            "headers": {
              "ETag": {
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The query string is invalid."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
    }
  }
}

Used command line:

dotnet kiota generate --language CSharp --class-name HeadersClient --namespace-name OpenApiKiotaEndToEndTests.Headers.GeneratedCode --output ./Headers/GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --log-level Error --openapi ../OpenApiTests/Headers/GeneratedSwagger/swagger.g.json

Generated client usage: image

Guida contributor