Skip to content

Recursive reference #347

Closed
Closed

Description

@Kludex

Describe the bug

So... I have this:

class FolderChildren(BaseModel):
    """
    Folder schema to output from GET folders/{folder_id}/children method.
    """

    id: int
    name: str
    n_docs: int
    children: Optional[List["FolderChildren"]] = None

FolderChildren.update_forward_refs()

And the error is:

Warning(s) encountered while generating. Client was generated, but some pieces may be missing

WARNING parsing GET /api/v1/folders/{folder_id}/children/ within hierarchy.

Cannot parse response for status code 200, response will be ommitted from generated client

Reference(ref='#/components/schemas/FolderChildren')

Unable to parse this part of your OpenAPI document: 

invalid data in items of array children

Reference(ref='#/components/schemas/FolderChildren')

I believe the problem is the self-reference. Am I wrong?

Expected behavior
Not having the error message.

OpenAPI Spec File
Can't give you this.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Python Version: 3.6.9
  • openapi-python-client version 0.8.0

Activity

  1. emann commented on Mar 12, 2021

    @emann
    Contributor

    Unfortunately recursively defined schemas aren't supported currently. There's a pull request (#329) to add support but we need to take another look at it. There's already a ticket for this (#338) so I'll close this for now - if this is still giving you issues once support is added feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions