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

Model types do not get generated correctly when referenced via an array #2338

Closed
darrelmiller opened this issue Feb 24, 2023 · 4 comments
Closed
Assignees
Labels
enhancement New feature or request generator Issues or improvements relater to generation capabilities. needs more information Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close

Comments

@darrelmiller
Copy link
Member

Sorry, I couldn't get this any simpler, but if you generate this you will see that the model types that are referenced in the array type, do not get generated properly. They do get emitted as types, but they don't have the property inheritance relationship and they have no properties.

openapi: '3.0.0'
info:
  title: Test
  version: '1.0'
paths:
  "/collection":
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/itemArray"
components:
  schemas:
    itemArray:
      type: object
      oneOf:
        - $ref: "#/components/schemas/catArray"  # cat does not get properties or base type
        - $ref: "#/components/schemas/dogArray" # dog does not get properties or base type
        - $ref: "#/components/schemas/frogArray" # frog does not get properties 
        - $ref: "#/components/schemas/squirrel" # squirrel works
    catArray:
      type: array
      items:
        $ref: "#/components/schemas/cat"
    cat:
      allOf:
        - $ref: "#/components/schemas/animal"
        - type: object
          properties:
            meow:
              type: string
    dogArray:
      type: array
      items:
        $ref: "#/components/schemas/dog"
    dog: 
      allOf:
        - $ref: "#/components/schemas/animal"
        - type: object
          properties:
            woof:
              type: string
    frog:
      type: object
      properties:
        croak:
          type: string
    frogArray:
      type: array
      items:
        $ref: "#/components/schemas/frog"
    squirrel:
      type: object
      properties:
        chitter:
          type: string
    animal:
      type: object
      properties:
        name:
          type: string
@baywet
Copy link
Member

baywet commented Feb 26, 2023

Union and intersection of array types were excluded from the initial composed types implementation. Or at least this is what I took away from our discussions.
Besides projecting the right types, it poses a lot of challenges during deserialization.
So unless we decide to support that initial exclusion with a thorough implementation spec, I think we should consider all of these edge cases to avoid playing whack a mole.

@baywet baywet added enhancement New feature or request needs more information generator Issues or improvements relater to generation capabilities. and removed Needs: Triage 🔍 labels Feb 26, 2023
@baywet baywet added this to the Kiota post-GA milestone Feb 26, 2023
@baywet baywet added this to Kiota Feb 26, 2023
@github-project-automation github-project-automation bot moved this to Todo in Kiota Feb 26, 2023
@darrelmiller
Copy link
Member Author

I think the best thing to do at this point is to take the time to write a proper analysis of what additional vocab we need to do in JSON Schema in order to allow developer to properly communicate how types should be projected. Until we do that, we shouldn't try and piecemeal solve issues in Kiota. I just wanted to capture this issue because it showed up in the NightScout API.

@baywet
Copy link
Member

baywet commented May 17, 2024

@darrelmiller can you please try with the latest preview from yesterday and confirm whether you observe the problem? We've made significant improvements to the handling of allof edge scenarios with #4668 and #4381

@baywet baywet added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label May 17, 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.

@microsoft-github-policy-service microsoft-github-policy-service bot removed this from the Backlog milestone May 24, 2024
@github-project-automation github-project-automation bot moved this from Todo 📃 to Done ✔️ in Kiota May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request generator Issues or improvements relater to generation capabilities. needs more information Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Projects
Archived in project
Development

No branches or pull requests

2 participants