-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,139 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroArraySchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#Arrays">Arrays</a> | ||
*/ | ||
public class AvroArraySchema { | ||
|
||
@NotNull | ||
@JsonProperty("items") | ||
private String items; | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroEnumSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Avro Enum Schema | ||
* | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#Enums">Enums</a> | ||
*/ | ||
public class AvroEnumSchema { | ||
|
||
@NotNull | ||
@JsonProperty("name") | ||
private String name = ""; | ||
|
||
@Nullable | ||
@JsonProperty("namespace") | ||
private String namespace; | ||
|
||
/** | ||
* A JSON string providing documentation to the user of this schema (optional). | ||
*/ | ||
@Nullable | ||
private String doc; | ||
|
||
/** | ||
* A JSON array, listing symbols, as JSON strings (required). | ||
* <p> | ||
* All symbols in an enum must be unique; duplicates are prohibited. | ||
* <p> | ||
* Every symbol must match the regular expression [A-Za-z_][A-Za-z0-9_]* (the same requirement as for <a href="https://avro.apache.org/docs/1.9.0/spec.html#names">names</a>). | ||
*/ | ||
@NotNull | ||
private List<@NotNull String> symbols = Collections.emptyList(); | ||
|
||
/** | ||
* A JSON array of strings, providing alternate names for this record (optional). | ||
*/ | ||
@Nullable | ||
@JsonProperty("aliases") | ||
private List<@NotNull String> aliases; | ||
|
||
/** | ||
* A default value for this enumeration, used during resolution when the reader encounters a symbol | ||
* from the writer that isn't defined in the reader's schema (optional). | ||
* <p> | ||
* The value provided here must be a JSON string that's a member of the symbols array. | ||
* <p> | ||
* See documentation on schema resolution for how this gets used. | ||
*/ | ||
@Nullable | ||
@JsonProperty("default") | ||
private String defaultValue; | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroFixedSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#Arrays">Arrays</a> | ||
*/ | ||
public class AvroFixedSchema { | ||
|
||
@NotNull | ||
@JsonProperty("name") | ||
private String name; | ||
|
||
/** | ||
* A JSON string that qualifies the name. | ||
*/ | ||
@Nullable | ||
@JsonProperty("namespace") | ||
private String namespace; | ||
|
||
/** | ||
* A JSON array of strings, providing alternate names for this record (optional). | ||
*/ | ||
@Nullable | ||
private List<@NotNull String> aliases; | ||
|
||
/** | ||
* An integer, specifying the number of bytes per value (required). | ||
*/ | ||
@NotNull | ||
private Integer size; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroMapSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#Maps">Maps</a> | ||
*/ | ||
public class AvroMapSchema { | ||
|
||
@NotNull | ||
@JsonProperty("values") | ||
private String values; | ||
|
||
} |
157 changes: 157 additions & 0 deletions
157
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroRecordFieldSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Avro Record Field. | ||
* | ||
* @author Pavel Bodiachevskii | ||
* @version 3.0.0 | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#schema_record">Avro Record</a> | ||
*/ | ||
public class AvroRecordFieldSchema extends AvroSchema { | ||
|
||
public AvroRecordFieldSchema() { | ||
super(AvroSchemaType.RECORD); | ||
} | ||
|
||
/** | ||
* Field type. | ||
*/ | ||
@NotNull | ||
@JsonProperty("type") | ||
private Object type; | ||
|
||
/** | ||
* A JSON string providing the name of the record (required). | ||
*/ | ||
@NotNull | ||
@JsonProperty("name") | ||
private String name = ""; | ||
|
||
/** | ||
* Specifies how this field impacts sort ordering of this record (optional). | ||
*/ | ||
@Nullable("order") | ||
private Order order = Order.ASCENDING; | ||
|
||
/** | ||
* A JSON string providing documentation to the user of this schema (optional). | ||
*/ | ||
@Nullable | ||
@JsonProperty("doc") | ||
private String doc; | ||
|
||
/** | ||
* A JSON array of strings, providing alternate names for this record (optional). | ||
*/ | ||
@Nullable | ||
@JsonProperty("aliases") | ||
private List<@NotNull String> aliases; | ||
|
||
/** | ||
* A default value for this field, used when reading instances that lack this field (optional). | ||
* <p> | ||
* Permitted values depend on the field's schema type, according to the table below. | ||
* <p> | ||
* Default values for union fields correspond to the first schema in the union. | ||
* <p> | ||
* Default values for bytes and fixed fields are JSON strings, where Unicode code points 0-255 are mapped to unsigned 8-bit byte values 0-255. | ||
* | ||
* <pre> | ||
* <table> | ||
* <tr> | ||
* <th>avro type</th> | ||
* <th>json type</th> | ||
* <th>example</th> | ||
* </tr> | ||
* <tr> | ||
* <td>null</td> | ||
* <td>null</td> | ||
* <td>null</td> | ||
* </tr> | ||
* <tr> | ||
* <td>boolean</td> | ||
* <td>boolean</td> | ||
* <td>true</td> | ||
* </tr> | ||
* <tr> | ||
* <td>int, long</td> | ||
* <td>integer</td> | ||
* <td>1</td> | ||
* </tr> | ||
* <tr> | ||
* <td>float, double</td> | ||
* <td>number</td> | ||
* <td>1.1</td> | ||
* </tr> | ||
* <tr> | ||
* <td>bytes</td> | ||
* <td>string</td> | ||
* <td>"\u00FF"</td> | ||
* </tr> | ||
* <tr> | ||
* <td>string</td> | ||
* <td>string</td> | ||
* <td>"foo"</td> | ||
* </tr> | ||
* <tr> | ||
* <td>record</td> | ||
* <td>object</td> | ||
* <td>{"a": 1}</td> | ||
* </tr> | ||
* <tr> | ||
* <td>enum</td> | ||
* <td>string</td> | ||
* <td>"FOO"</td> | ||
* </tr> | ||
* <tr> | ||
* <td>array</td> | ||
* <td>array</td> | ||
* <td>[1]</td> | ||
* </tr> | ||
* <tr> | ||
* <td>map</td> | ||
* <td>object</td> | ||
* <td>{"a": 1}</td> | ||
* </tr> | ||
* <tr> | ||
* <td>fixed</td> | ||
* <td>string</td> | ||
* <td>"\u00ff"</td> | ||
* </tr> | ||
* </table> | ||
* </pre> | ||
*/ | ||
@Nullable | ||
@JsonProperty("default") | ||
private Object defaultValue; | ||
|
||
/** | ||
* Specifies how this field impacts sort ordering of this record. | ||
* <p> | ||
* Valid values are "ascending" (the default), "descending", or "ignore". | ||
* <p> | ||
* For more details on how this is used, see the the sort order section. | ||
* | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#order">Order</a> | ||
*/ | ||
public enum Order { | ||
|
||
@JsonProperty("ascending") | ||
ASCENDING, | ||
|
||
@JsonProperty("descending") | ||
DESCENDING, | ||
|
||
@JsonProperty("ignore") | ||
IGNORE | ||
|
||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroRecordSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Avro Record. | ||
* | ||
* @author Pavel Bodiachevskii | ||
* @version 3.0.0 | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html#schema_record">Avro Record</a> | ||
*/ | ||
public class AvroRecordSchema extends AvroSchema { | ||
|
||
public AvroRecordSchema() { | ||
super(AvroSchemaType.RECORD); | ||
} | ||
|
||
/** | ||
* A JSON string providing the name of the record (required). | ||
*/ | ||
@NotNull | ||
private String name = ""; | ||
|
||
/** | ||
* A JSON string that qualifies the name. | ||
*/ | ||
@Nullable | ||
private String namespace; | ||
|
||
/** | ||
* A JSON string providing documentation to the user of this schema (optional). | ||
*/ | ||
@Nullable | ||
private String doc; | ||
|
||
/** | ||
* A JSON array of strings, providing alternate names for this record (optional). | ||
*/ | ||
@Nullable | ||
private List<@NotNull String> aliases; | ||
|
||
/** | ||
* A JSON array, listing fields (required). | ||
*/ | ||
@NotNull | ||
private List<@NotNull AvroRecordFieldSchema> fields = Collections.emptyList(); | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
asyncapi-core/src/main/java/com/asyncapi/v3/schema/avro/AvroSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.asyncapi.v3.schema.avro; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import lombok.Data; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Apache Avro Schema. | ||
* | ||
* @author Pavel Bodiachevskii | ||
* @version 3.0.0 | ||
* @see <a href="https://avro.apache.org/docs/1.9.0/spec.html">Avro Specification</a> | ||
*/ | ||
@Data | ||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.EXISTING_PROPERTY, | ||
property = "type", | ||
visible = true | ||
) | ||
@JsonSubTypes.Type(value = AvroSchema.class, names = { | ||
"null", "boolean", "int", "long", "float", "double", "bytes", "string" | ||
}) | ||
public class AvroSchema { | ||
|
||
/** | ||
* Avro Schema type. | ||
*/ | ||
@NotNull | ||
private AvroSchemaType type; | ||
|
||
} |
Oops, something went wrong.