openapi-generator-dart icon indicating copy to clipboard operation
openapi-generator-dart copied to clipboard

AnyOf doesn't code generate correctly.

Open domesticmouse opened this issue 3 years ago • 3 comments

I have a OpenAPI spec that includes the following component that confuses the openapi_generator to no end:

"ValidationError": {
    "title": "ValidationError",
    "required": [
        "loc",
        "msg",
        "type"
    ],
    "type": "object",
    "properties": {
        "loc": {
            "title": "Location",
            "type": "array",
            "items": {
                "anyOf": [
                    {
                        "type": "string"
                    },
                    {
                        "type": "integer"
                    }
                ]
            }
        },
        "msg": {
            "title": "Message",
            "type": "string"
        },
        "type": {
            "title": "Error Type",
            "type": "string"
        }
    }
}

This winds up with a AnyOfstringinteger which isn't generated.

domesticmouse avatar May 03 '22 04:05 domesticmouse

The source of this appears to be: https://github.com/tiangolo/fastapi/pull/4806

domesticmouse avatar May 03 '22 04:05 domesticmouse

I have the same problem. Any idea on how to fix this? I can do it manually as a temporary fix but I would like to have an example of how the code should look like.

gboscaro-imtech avatar Sep 01 '22 09:09 gboscaro-imtech

To me it looks like the OpenAPI Dart generator doesn't support anyOf: https://openapi-generator.tech/docs/generators/dart#schema-support-feature

As such, this is not an issue with this repo, but rather https://github.com/OpenAPITools/openapi-generator

szekelyisz avatar Jan 11 '23 13:01 szekelyisz