def test_schema_with_nested_object(self):
        data = {
            "ModelName": {
                "properties": {
                    "foo": {
                        "properties": {
                            "bar": {
                                "type": "string",
                            },
                        },
                        "type": "object",
                    },
                },
                "type": "object",
            },
        }
        parser = schemas.SchemaParser(data)
        result = parser.model_defs
        expected = {
            "ModelName":
            textwrap.dedent('''
                class ModelName(pydantic.BaseModel):
                    foo: "_foo"
            ''').lstrip(),
            "_foo":
            textwrap.dedent('''
                class _foo(pydantic.BaseModel):
                    bar: str
            ''').lstrip(),
        }

        assert result == expected
    def test_schema_with_string_property(self):
        data = {
            "ModelName": {
                "properties": {
                    "foo": {
                        "type": "string",
                    },
                },
                "type": "object",
            },
        }
        parser = schemas.SchemaParser(data)
        result = parser.model_defs
        expected = textwrap.dedent('''
            class ModelName(pydantic.BaseModel):
                foo: str
        ''').lstrip()

        assert result["ModelName"] == expected
    def test_schema_description_is_docstring(self):
        data = {
            "ModelName": {
                "description": "A ModelName instance.",
                "properties": {
                    "foo": {
                        "type": "string",
                    },
                },
                "type": "object",
            },
        }
        parser = schemas.SchemaParser(data)
        result = parser.model_defs
        expected = textwrap.dedent('''
            class ModelName(pydantic.BaseModel):
                """A ModelName instance."""
                foo: str
        ''').lstrip()

        assert result["ModelName"] == expected
    def test_schema_with_array_of_objects(self):
        data = {
            "ModelName": {
                "properties": {
                    "foo": {
                        "items": {
                            "$ref": "OtherName",
                        },
                        "type": "array",
                    },
                },
                "type": "object",
            },
        }
        parser = schemas.SchemaParser(data)
        result = parser.model_defs
        expected = textwrap.dedent('''
            class ModelName(pydantic.BaseModel):
                foo: List["OtherName"]
        ''').lstrip()

        assert result["ModelName"] == expected