FasterXML / FasterXML/jackson-dataformats-binary

[avro] Add support for external nullability annotations (JSpecify?)

Open
#147 5 comments 0 reactions 0 assignees View on GitHub
avro
Dominant language
Java
Stars
347
Forks
156
Avg merge
3d 3h
Merged PRs (30d)
22

Description

If I have a simple class

```
public class Foo {
private final String value;

public Foo(String aValue) {
value = aValue;
}

public String getValue() {
return value;
}
}
```
and generate a schema with:

```
import com.fasterxml.jackson.dataformat.avro.AvroMapper;
import com.fasterxml.jackson.dataformat.avro.AvroSchema;

import java.io.IOException;

public class Main {
public static void main(String[] args) throws IOException {
AvroSchema myAvroSchema = new AvroMapper().schemaFor(Foo.class);
System.out.println(myAvroSchema.getAvroSchema().toString(true));
}
}
```

I get:

```
{
"type" : "record",
"name" : "Foo",
"fields" : [ {
"name" : "value",
"type" : [ "null", "string" ]
} ]
}
```

Primitive fields are not marked nullable. No `@NotNull` or `@Nonnull` annotation seems to change the generated schema to have non-null fields. Am I doing something wrong?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.