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

Avoid IComposedTypeWrapper for common base class? #5435

Closed
lvde0 opened this issue Sep 18, 2024 · 4 comments
Closed

Avoid IComposedTypeWrapper for common base class? #5435

lvde0 opened this issue Sep 18, 2024 · 4 comments
Labels
generator Issues or improvements relater to generation capabilities. 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

@lvde0
Copy link

lvde0 commented Sep 18, 2024

Is your feature request related to a problem? Please describe the problem.

Kiota generates IComposedTypeWrapper for oneof sets. This is fine when the types in the set don't share a common base schema ("inherited" via allof), but I think it would be much nicer to just generate the base class directly when they do?

Example:

 "animals": {
   "type": "array",
   "items": {
     "oneOf": [
       {
         "$ref": "#/components/schemas/Dog"
       },
       {
         "$ref": "#/components/schemas/Cat"
       },
       {
         "$ref": "#/components/schemas/Mouse"
       }
     ]
   }
 }

Ideally this should generate List<Animal> not List<IComposedTypeWrapper>. Is this possible somehow?

Client library/SDK language

Csharp

Describe the solution you'd like

Additional context

No response

@lvde0 lvde0 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Sep 18, 2024
@msgraph-bot msgraph-bot bot added the Csharp Pull requests that update .net code label Sep 18, 2024
@baywet
Copy link
Member

baywet commented Sep 23, 2024

HI @lvde0
Thank you for using kiota and for reaching out.

This approach would be making the assumption these member types somehow have something in common (besides being used at the same place), which is not always true (depends on the API design).

What limitations are you facing here?

@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 generator Issues or improvements relater to generation capabilities. and removed Csharp Pull requests that update .net code status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Sep 23, 2024
@lvde0
Copy link
Author

lvde0 commented Sep 30, 2024

@baywet Yes, it might not always be the case. But I am proposing that when the types share the same "base type" we could simply return a list of base type instead of IComposedTypeWrapper. It's not critical, but it would be a nice QOL addition IMO.

@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 Sep 30, 2024
@baywet
Copy link
Member

baywet commented Sep 30, 2024

Thank you for the additional information.

The challenge with this approach is that it might not work in all cases. Especially if types are used different places like a union type at one place and an inheritance hierarchy at another. Making that change would translate in serialization/deserialization issues.

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 and removed Needs: Attention 👋 labels Sep 30, 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
generator Issues or improvements relater to generation capabilities. 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