Skip to content

Commit 15b01e7

Browse files
committed
README updates.
1 parent 64713ad commit 15b01e7

File tree

2 files changed

+87
-78
lines changed

2 files changed

+87
-78
lines changed

README.markdown

-78
This file was deleted.

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[![License LGPLv3][LGPLv3 badge]][LGPLv3]
2+
[![License ASL 2.0][ASL 2.0 badge]][ASL 2.0]
3+
[![Build Status][Travis badge]][Travis]
4+
[![Maven Central][Maven Central badge]][Maven]
5+
6+
## Read me first
7+
8+
This project, as of version 0.1.4, is licensed under both LGPLv3 and ASL 2.0. See
9+
file LICENSE for more details. Versions 0.1.3 and lower are licensed under LGPLv3
10+
only.
11+
12+
**Note the "L" in "LGPL". LGPL AND GPL ARE QUITE DIFFERENT!**
13+
14+
## What this is
15+
16+
This package contains two processors (see
17+
[json-schema-core](https://github.com/java-json-tools/json-schema-core)) to
18+
convert Avro schemas to JSON Schemas, and the reverse.
19+
20+
## Status
21+
22+
### Avro schemas to JSON Schema
23+
24+
This processor can transform **all** Avro schemas you can think of, as long as said schemas
25+
are self contained. The generated JSON Schemas can accurately validate JSON representations of Avro
26+
data with two exceptions:
27+
28+
* as JSON has no notion of order, the `order` property of
29+
Avro records is not enforced;
30+
* Avro's `float` and `double` are validated as JSON numbers, with no minimum or
31+
maximum, see below as to why. Note however that `int`
32+
and `long`'s limits *are* enforced.
33+
34+
Note that this processor is demoed online
35+
[here](http://json-schema-validator.herokuapp.com/avro.jsp).
36+
37+
## JSON Schema to Avro schemas
38+
39+
This processor is not complete yet. It is *much* more difficult to write than the reverse for two
40+
reasons:
41+
42+
* JSON Schema can describe a much broader set of data than Avro (Avro can only have strings in
43+
enums, for instance, while enums in JSON Schema can have any JSON value);
44+
* but Avro has notions which are not available in JSON (property order in records, binary types).
45+
46+
The generated Avro schemas are however reasonably good, and cover a very large subset of JSON
47+
Schema usages.
48+
49+
This processor is not available online yet; it will soon be.
50+
51+
## Why limits are not enforced on Avro's `float` and `double`
52+
53+
While JSON Schema has `minimum` and `maximum` to enforce the minimum and maximum values of a JSON
54+
number, JSON numbers ([RFC 4627 §2.4](https://tools.ietf.org/html/rfc4627#section-2.4)) do not
55+
define any limit to the scale and/or precision of numbers.
56+
57+
That is a first reason, but then one should ask why then, are there limits for `int` and `long`.
58+
There are two reasons for this:
59+
60+
* JSON Schema defines integer (as a number with no fractional and/or exponent part); integer being
61+
a discrete domain, such limits can therefore be defined without room for error;
62+
* but Avro's `float` and `double` are IEEE 754 floating point numbers; they do have minimums and
63+
maximums, but 0.1, for instance, cannot even be represented exactly in a double.
64+
65+
Defining limits would therefore not ensure that the JSON number being validated can indeed fit
66+
into the corresponding Avro type.
67+
68+
## Maven artifact
69+
70+
```xml
71+
<dependency>
72+
<groupId>com.github.java-json-tools</groupId>
73+
<artifactId>json-schema-avro</artifactId>
74+
<version>your-version-here</version>
75+
</dependency>
76+
```
77+
78+
Versions before 0.1.5 are available at `groupId` `com.github.fge`.
79+
80+
[LGPLv3 badge]: https://img.shields.io/:license-LGPLv3-blue.svg
81+
[LGPLv3]: http://www.gnu.org/licenses/lgpl-3.0.html
82+
[ASL 2.0 badge]: https://img.shields.io/:license-Apache%202.0-blue.svg
83+
[ASL 2.0]: http://www.apache.org/licenses/LICENSE-2.0.html
84+
[Travis Badge]: https://api.travis-ci.org/java-json-tools/json-schema-avro.svg?branch=master
85+
[Travis]: https://travis-ci.org/java-json-tools/json-schema-avro
86+
[Maven Central badge]: https://img.shields.io/maven-central/v/com.github.java-json-tools/json-schema-avro.svg
87+
[Maven]: https://search.maven.org/artifact/com.github.java-json-tools/json-schema-avro

0 commit comments

Comments
 (0)