Invalid Avro namespace generation on nested structures

19 Views Asked by At

I'm using Debezium with EventRouter SMT (Outbox Pattern) and I'm generating Avro schemas on the fly based on the JSON payload. Right now I'm having an issue where nested structures are not properly getting namespaced.

{
    "type": "record",
    "name": "NotificationsRecord",
    "namespace": "my.namespace.avroschemas.servicea",
    "fields": [
        {
            "name": "id",
            "type": [
                "null",
                "string"
            ],
            "default": null
        },
        {
            "name": "email",
            "type": [
                "null",
                "string"
            ],
            "default": null
        },
        {
            "name": "isActive",
            "type": [
                "null",
                "boolean"
            ],
            "default": null
        },
        {
            "name": "lastName",
            "type": [
                "null",
                "string"
            ],
            "default": null
        },
        {
            "name": "username",
            "type": [
                "null",
                "string"
            ],
            "default": null
        },
        {
            "name": "firstName",
            "type": [
                "null",
                "string"
            ],
            "default": null
        },
        {
            "name": "additionalData",
            "type": [
                "null",
                {
                    "type": "record",
                    "name": "additionalData",
                    "namespace": "payload", <--- invalid namespace here
                    "fields": [
                        {
                            "name": "email",
                            "type": [
                                "null",
                                "string"
                            ],
                            "default": null
                        },
                        {
                            "name": "token",
                            "type": [
                                "null",
                                "string"
                            ],
                            "default": null
                        },
                        {
                            "name": "secret",
                            "type": [
                                "null",
                                "string"
                            ],
                            "default": null
                        },
                        {
                            "name": "temporary_password",
                            "type": [
                                "null",
                                "string"
                            ],
                            "default": null
                        },
                        {
                            "name": "notification_template",
                            "type": [
                                "null",
                                "string"
                            ],
                            "default": null
                        }
                    ],
                    "connect.name": "payload.additionalData"
                }
            ],
            "default": null
        },
        {
            "name": "isEmailVerified",
            "type": [
                "null",
                "boolean"
            ],
            "default": null
        }
    ],
    "connect.name": "my.namespace.avroschemas.servicea.NotificationsRecord"
}

Does anyone know how to get rid of that unnecessary namespace? It causes invalid class generation when generating classes

0

There are 0 best solutions below