Skip to content

Missing import when there is a const in the object #1074

Open
@dorcohe

Description

@dorcohe

Describe the bug
Version: 0.21.1
When I try to generate a client it fails with the following error:
Error(s) encountered while generating, client was not created

ruff failed

rivery_scim_client/models/book.py:40:21: F821 Undefined name cast
Found 209 errors (208 fixed, 1 remaining).

As you can see there is an import missing. I publish a PR that should solve it.
#1072

OpenAPI Spec File
I created a dummy openapi specification.

{
    "openapi": "3.1.0",
    "info": {
        "title": "FastAPI",
        "version": "0.1.0"
    },
    "paths": {
        "/books": {
            "post": {
                "summary": "Create User",
                "operationId": "create_user_books_post",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/Book"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "200": {
                        "description": "Successful Response",
                        "content": {
                            "application/json": {
                                "schema": {}
                            }
                        }
                    },
                    "422": {
                        "description": "Validation Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Book": {
                "properties": {
                    "item_type": {
                        "const": "book",
                        "title": "Item Type",
                        "default": "book"
                    }
                },
                "type": "object",
                "title": "Book"
            },
            "ErrorResponse": {
                "properties": {
                    "schemas": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array",
                        "title": "Schemas",
                        "default": [
                            "urn:ietf:params:scim:api:messages:2.0:Error"
                        ]
                    },
                    "status": {
                        "type": "integer",
                        "title": "Status"
                    },
                    "details": {
                        "type": "string",
                        "title": "Details"
                    }
                },
                "type": "object",
                "required": [
                    "status",
                    "details"
                ],
                "title": "ErrorResponse"
            },
            "HTTPValidationError": {
                "properties": {
                    "detail": {
                        "items": {
                            "$ref": "#/components/schemas/ValidationError"
                        },
                        "type": "array",
                        "title": "Detail"
                    }
                },
                "type": "object",
                "title": "HTTPValidationError"
            },
            "ValidationError": {
                "properties": {
                    "loc": {
                        "items": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "integer"
                                }
                            ]
                        },
                        "type": "array",
                        "title": "Location"
                    },
                    "msg": {
                        "type": "string",
                        "title": "Message"
                    },
                    "type": {
                        "type": "string",
                        "title": "Error Type"
                    }
                },
                "type": "object",
                "required": [
                    "loc",
                    "msg",
                    "type"
                ],
                "title": "ValidationError"
            }
        },
        "securitySchemes": {
            "HTTPBearer": {
                "type": "http",
                "scheme": "bearer"
            }
        }
    }
}

Additional context
Add any other context about the problem here.
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions