FasterXML / FasterXML/jackson-dataformats-binary

Inability to specify custom namespace for `java-key-class` entries when using `@AvroNamespace` annotation in those classes

オープン
#611 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
avro good first issue pr-needed
主要言語
Java
スター
347
フォーク
156
平均マージ
3日 3時間
マージ済み PR(30日)
22

説明

Hey, so when generating a avro schema using the `AvroMapper` and `AvroSchemaGenerator`, thanks to #310 we can specify the custom namespace each class should have. Now, given a class

ExampleClass.java

``` java
package com.example.test

import com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespace;

import java.util.Map;

@AvroNamespace("com.github.test")
public class ExampleClass {

public Map exampleMap;
}

```
and the enum

ExampleEnum.java

``` java
package com.example.test

import com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespace;

@AvroNamespace("com.github.test")
public enum ExampleEnum {
FOO, BAR
}
```
, generating the schema by calling both classes explicitely (since nested generation doesn't work here) will yield

ExampleClass.avsc

``` avsc
{
"type" : "record",
"name" : "ExampleClass",
"namespace" : "com.github.test",
"fields" : [ {
"name" : "exampleMap",
"type" : [ "null", {
"type" : "map",
"values" : "string",
"java-key-class" : "com.example.test"
} ]
} ]
}
```
and

ExampleEnum.avsc

``` avsc
{
"type" : "enum",
"name" : "ExampleEnum",
"namespace" : "com.github.test",
"symbols" : [ "FOO", "BAR" ]
}
```

Notice how the specified `java-key-class` has the wrong namespace defined, since it is simply resolving the package name of the existing Java object.
The likely correct way would be to fetch the contents of the `@AvroNamespace` annotation inside the enum class and resolve it that way when a `java-key-class` entry is generated, if possible, and otherwise resolve it the old way.
Because I'm not sure of that possiblity though, another suggestion would be to implement an `@AvroKeyClass` annotation to be able to manually override that package definition.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。