Kriskras99 commented on issue #365:
URL: https://github.com/apache/avro-rs/issues/365#issuecomment-3681424741

   What schema should we generate for the following enum?:
   ```rust
   #[derive(AvroSchema, Serialize, Deserialize)]
   struct Bar {
       a: String
   };
   
   #[derive(AvroSchema, Serialize, Deserialize)]
   enum Foo {
       One(Bar),
       Two(Bar),
   }
   ```
   The derive for `Foo` can only control the namespace in the schema returned 
by `Bar`, so both variants will have the same Record schema which is not 
allowed by spec. We could add the enum variant to the namespace giving 
something like this:
   ```json
   [
       {
           "type": "record",
           "name": "Bar",
           "namespace": "A",
           "fields": [{"name": "a", "type": "string"}]
       },
       {
           "type": "record",
           "name": "Bar",
           "namespace": "B",
           "fields": [{"name": "a", "type": "string"}]
       }
   ]
   ```
   And when the union is already in a namespace:
   ```json
   {
       "type": "record",
       "name": "Outer",
       "namespace": "some.name.space",
       "fields": [
           {
               "name": "enum", 
               "type": [
                   {
                       "type": "record",
                       "name": "Bar",
                       "namespace": "some.name.space.A",
                       "fields": [{"name": "a", "type": "string"}]
                   },
                   {
                       "type": "record",
                       "name": "Bar",
                       "namespace": "some.name.space.B",
                       "fields": [{"name": "a", "type": "string"}]
                   }
               ]
           }
       ]
   }
   ```
   
   If we don't want to touch the namespace, the the current implementation 
(record with enum and union) is the only option left I think.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to