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

handle nullable in allOf #251

Open
zhuscat opened this issue Jul 19, 2024 · 0 comments
Open

handle nullable in allOf #251

zhuscat opened this issue Jul 19, 2024 · 0 comments
Assignees

Comments

@zhuscat
Copy link

zhuscat commented Jul 19, 2024

Steps to reproduce

I have a swagger schema like this:

...
                    "coverImage": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/DisplayImage"
                            },
                            {
                                "nullable": true
                            }
                        ]
                    }
...

Expected results

DisplayImage? coverImage

Actual results

dynamic coverImage

Your OpenApi snippet

{
    "info": {
        "title": "An API",
        "version": "v1"
    },
    "openapi": "3.0.0",
    "components": {
        "schemas": {
            "DisplayImage": {
                "type": "object",
                "properties": {
                    "uri": {
                        "type": "string"
                    },
                    "width": {
                        "type": "integer",
                        "nullable": true
                    },
                    "height": {
                        "type": "integer",
                        "nullable": true
                    },
                    "blurhash": {
                        "type": "string",
                        "nullable": true
                    },
                    "displayUrl": {
                        "type": "string"
                    }
                },
                "required": [
                    "uri",
                    "displayUrl"
                ]
            },
            "Test1Response": {
                "type": "object",
                "properties": {
                    "coverImage": {
                        "$ref": "#/components/schemas/DisplayImage"
                    },
                    "message": {
                        "type": "string"
                    }
                },
                "required": [
                    "coverImage",
                    "message"
                ]
            }
        },
        "parameters": {}
    },
    "paths": {
        "/test/test1": {
            "get": {
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Test1Response"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/test/test2": {
            "get": {
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Test1Response"
                                        },
                                        {
                                            "properties": {
                                                "coverImage": {
                                                    "allOf": [
                                                        {
                                                            "$ref": "#/components/schemas/DisplayImage"
                                                        },
                                                        {
                                                            "nullable": true
                                                        }
                                                    ]
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Code sample

No response

Logs

No response

Dart version and used packages versions

3.4.3

@StarProxima StarProxima self-assigned this Jul 19, 2024
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

No branches or pull requests

2 participants