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

[Python] array of arrays not generated #5159

Closed
geometrikal opened this issue Aug 14, 2024 · 8 comments
Closed

[Python] array of arrays not generated #5159

geometrikal opened this issue Aug 14, 2024 · 8 comments
Labels
Python 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

@geometrikal
Copy link

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Windows executable

Client library/SDK language

Python

Describe the bug

I'm trying to generate a client for the CVAT API

An openapi compenent property that is an array of array does not generate any corresponding property in the python model

job_file_mapping:
  type: array
  items:
    type: string
    items:
      type: string
      minLength: 1
      maxLength: 1024
  writeOnly: true
  description: |2

Expected behavior

For the above, generate job_file_mapping: Optional[List[List[str]]] = None

How to reproduce

See above

Open API description file

No response

Kiota Version

1.17.0+1eb16cd65853c17179e2dde3ae6098135deacf55

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

_No response_
@geometrikal geometrikal added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Aug 14, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Aug 14, 2024
@msgraph-bot msgraph-bot bot added the Python label Aug 14, 2024
@baywet
Copy link
Member

baywet commented Aug 14, 2024

Hi @geometrikal
Thank you for using kiota and for reaching out.
This is a limitation by design. Supporting multi-dimensional arrays would have lead to convoluted code both on the generation side but also on the parse node/serialization writer infrastructure.
Additionally, not a lot of APIs leverage this design as it does not provide a great experience to client applications and it's error prone.

#4385 would help support this scenario in python though through allowing you to pass "arbitrary" data to the property.
Let us know if you have any additional comments or 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 and removed type:bug A broken experience status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Aug 14, 2024
@baywet baywet moved this from Needs Triage 🔍 to Waits for author 🔁 in Kiota Aug 14, 2024
@geometrikal
Copy link
Author

I hope you reconsider - I've seen this a bit in the APIs I consume, things like lists of lists of float for polygon coordinates.

I believe it is valid openapi to have nested arrays?

Believe it or not, if I put type: list[str] in place of the nested array, kiota will generate working code for Python serialization.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Status: No Recent Activity labels Aug 21, 2024
@baywet
Copy link
Member

baywet commented Aug 21, 2024

Thank you for the additional information.

I believe it is valid openapi to have nested arrays?

yes, OAS doesn't have any opinion on the shape of the data.

Believe it or not, if I put type: list[str]

you probably mean on the API side? which results in a one dimensional array in the description and in the client? If that's the case yes one dimension arrays are perfectly supported today.

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 21, 2024
@geometrikal
Copy link
Author

Haha, no if I put

job_file_mapping:
  type: array
  items:
    type: list[str]

I can trick kiota into creating the property and serializing it. I don't imagine deserialization will work.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 21, 2024
@baywet
Copy link
Member

baywet commented Aug 22, 2024

Thank you for the additional information.

To recap:

  • current behaviour: does not generate any property.
  • "hack": put the python type directly, but deserialization probably does not work.

Is that an accurate representation of the situation?

What if instead of waiting for the next major release, which we currently don't have a schedule for, the property was generated but with "UntypedNode" instead?

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 22, 2024
@geometrikal
Copy link
Author

Yes, thanks

I would love it if it was supported directly, but I think that anything that enables the functionality, even if it is a workaround, without having to change the schema would be welcome. So if UntypedNode does that, I think that is good.

What do you think - maybe everything that is not currently implemented properly could be instead exposed as UntypedNode?The other big one for me is oneOf without a discriminator (which are optional according to openapi spec), seems like a common pattern.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 22, 2024
@baywet
Copy link
Member

baywet commented Aug 23, 2024

Can you create a separate issue for one of please? I'd like the conversation here to stay focused so we're more likely to get to action items and resolution.

For the untypednode solution to work end to end in python, we'd be depending on #4385 to get done. But we already have ongoing PRs for that!

For the generator changes is this something you'd like to submit a pull request for provided some guidance?

@baywet baywet added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Aug 23, 2024
@baywet baywet added this to the Backlog milestone Aug 23, 2024
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python 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