Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
draw13 opened this issue Aug 2, 2024 · 2 comments
Closed
Labels
Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question

Comments

@draw13
Copy link

draw13 commented Aug 2, 2024

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.

@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Aug 2, 2024
@baywet
Copy link
Member

baywet commented Aug 2, 2024

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.

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question labels Aug 2, 2024
@baywet baywet moved this from Needs Triage 🔍 to Waits for author 🔁 in Kiota Aug 2, 2024

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.

@github-project-automation github-project-automation bot moved this from Waits for author 🔁 to Done ✔️ in Kiota Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question
Projects
Archived in project
Development

No branches or pull requests

2 participants