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

null missing in generated typescript for sibling properties of recursive schemas when only one option provided in "oneOf" #297

Open
DustyLamp opened this issue Jul 20, 2024 · 0 comments

Comments

@DustyLamp
Copy link

Describe the bug
Generated Typescript for properties that refer to a schema where sibling properties are recursive are missing null in union when only a single option is included in "oneOf" .

Minimal reproduction

{
    "openapi": "3.0.0",
    "info": {
        "title": "The API",
        "contact": {
            "email": "[email protected]"
        },
        "version": "1.0.0"
    },
    "paths": {
        "/api/hello": {
            "get": {
                "summary": "Hello",
                "operationId": "sayHello",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/Foo"
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Bar": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    }
                }
            },
            "Foo": {
                "type": "object",
                "properties": {
                    "bar": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/Bar"
                            }
                        ],
                        "nullable": true
                    },
                    "foos": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Foo"
                        }
                    }
                }
            }
        }
    }
}

Expected behavior
What was generated:

...
export type Foo = Partial<{
    bar: Bar;
    foos: Array<Foo>;
}>;
...

What is expected:

...
export type Foo = Partial<{
    bar: Bar | null;
    foos: Array<Foo>;
}>;
...
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

1 participant