microsoft / kiota-dotnet

Abstractions library for the Kiota generated SDKs in dotnet
https://aka.ms/kiota/docs
MIT License
33 stars 30 forks source link

UntypedNode result is generated from action that returns array of arrays #318

Closed draw13 closed 1 month ago

draw13 commented 1 month ago

Hi everyone! I'm trying to generate api client from the following action:

    [HttpGet("models")]
    public Task<Model[][]> GetModelsAsync(
        [FromServices] IModelsService service,
        CancellationToken cancellationToken)
        => service.GetModelsAsync(cancellationToken);

openapi schema:

"200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Model"
              }
            }
          }
        }
      }
    }

"schemas": {
  "Model": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer",
        "format": "int32"
      },
      "text": {
        "type": "string",
        "nullable": true
      },
    },
    "additionalProperties": false
  }
}

output:

        public async Task<UntypedNode> GetAsync(...)
        {
            var requestInfo = ToGetRequestInformation(requestConfiguration);
            var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
            {
                { "401", global::Models.ApiError.CreateFromDiscriminatorValue },
                { "403", global::Models.ApiError.CreateFromDiscriminatorValue },
                { "404", global::Models.ApiError.CreateFromDiscriminatorValue },
                { "500", global::Models.ApiError.CreateFromDiscriminatorValue },
            };
            return await RequestAdapter.SendAsync<UntypedNode>(requestInfo, UntypedNode.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
        }

Why UntypedNode is generated for this case? Is there is a way how to fix it?

Thanks.

baywet commented 1 month ago

Hi @draw13 Thanks for using kiota and for reaching out. This is expected behaviour. While designing kiota we restricted the generated types to: object, scalars, arrays of objects (one dimension), arrays of scalars (one dimension) recursively. The reason why we have this restriction in place is because supporting generation for more advanced cases would complexify the code generation quite a lot, and from looking at existing descriptions out there, it wasn't that common. Let us know if you have further questions.

microsoft-github-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.