gibahjoe / openapi-generator-dart

Openapi Generator for Dart/Flutter
BSD 3-Clause "New" or "Revised" License
128 stars 34 forks source link

AnyOf doesn't code generate correctly. #69

Closed domesticmouse closed 4 days ago

domesticmouse commented 2 years ago

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 commented 2 years ago

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

gboscaro-imtech commented 2 years ago

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.

szekelyisz commented 1 year ago

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

gibahjoe commented 4 days ago

I know it has been a while but in case anyone else stumbles on this, Anyof support has been added to the dio generator.