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

🐛 fix importing nested models. #56

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DaniinXorchenabo
Copy link

trigger swagger fragment

 "Ans_UserDTO_Union_BError__NoneType__": {
        "properties": {
          "errors": {
            "anyOf": [
              {
                "items": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/BError"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Errors"
          },
         
        },
        "type": "object",
        "title": "Ans[Union[BError, NoneType]]"
      },

generated:

# Ans_Union_BError__NoneType__.py file

from typing import *

from pydantic import BaseModel, Field


class Ans_UserDTO_Union_BError__NoneType__(BaseModel):
    """
    Ans[Union[BError, NoneType]] model

    """

    errors: Optional[Union[List[Union[BError, None]], None]] = Field(alias="errors", default=None)

expected correct behavior:

# Ans_Union_BError__NoneType__.py file

from typing import *

from pydantic import BaseModel, Field

from .BError import BError


class Ans_UserDTO_Union_BError__NoneType__(BaseModel):
    """
    Ans[Union[BError, NoneType]] model

    """

    errors: Optional[Union[List[Union[BError, None]], None]] = Field(alias="errors", default=None)

@MarcoMuellner
Copy link
Owner

Hey @DaniinXorchenabo can you add some regression tests that show the wrong behaviour, and prove that this fixes it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants