json-schema
Version, currently 1.2.011 versions
- 1.3.3latestJun 14, 2026
- 1.3.2not indexedJun 14, 2026
- 1.3.1not indexedJun 14, 2026
- 1.3.0not indexedJun 14, 2026
- 1.2.1not indexedJun 14, 2026
- 1.2.0not indexedJun 14, 2026
- 1.1.1not indexedJun 14, 2026
- 1.1.0not indexedJun 14, 2026
- 1.0.2not indexedJun 14, 2026
- 1.0.1not indexedJun 14, 2026
- 1.0.0not indexedJun 14, 2026
github.com/spider-gazelle/json-schema
Describe crystal-lang JSON serializable types with JSON Schema
15 stars
1 dependent
License: MIT
Nothing has been indexed for 1.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
json-schema:
github: spider-gazelle/json-schema
version: ~> 1.2.0Then run:
shards installshard.yml
No shard.yml has been indexed for 1.2.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# JSON Schema [](https://github.com/spider-gazelle/json-schema/actions/workflows/ci.yml)
A crystal lang tool for converting JSON serialisable class definitions into the [JSON Schema](https://json-schema.org/) representation.
## Installation
```yaml
dependencies:
json-schema:
github: spider-gazelle/json-schema
```
## Usage
basic type support
```crystal
require "json-schema"
String.json_schema #=> {type: "string"}
Int32.json_schema #=> {type: "integer", format: "Int32"}
Float32.json_schema #=> {type: "number", format: "Float32"}
Array(String | Int32).json_schema #=> { type: "array", items: { anyOf: [{type: "integer", format: "Int32"}, {type: "string"}] } }
# Works with enums
enum TestEnum
Option1
Option2
end
TestEnum.json_schema #=> {type: "string", enum: ["option1", "option2"]}
```
json serialisable support is included too, with deeply nested objects etc.
```crystal
require "json-schema"
class MyType
include JSON::Serializable
getter string : String
getter symbol : Symbol?
getter time : Time
getter integer : Int32
getter union_type : String | Int64 | Bool
end
MyType.json_schema
# outputs
{
type: "object",
properties: {
string: {type: "string"},
symbol: {type: "string"},
time: {type: "string", format: "date-time"},
integer: {type: "integer", format: "Int32"},
union_type: {anyOf: [{type: "boolean"}, {type: "integer", format: "Int64"}, {type: "string"}]}
},
required: ["string", "time", "integer", "union_type"]
}
```
You can also customize schema output using the `@[JSON::Field]` annotation
```crystal
require "json-schema"
class MyType
include JSON::Serializable
# The `EpochConverter` here means the JSON value will actually be an integer
# so to avoid the output being `type: "string", format: "date-time"` you can
# supply a type override and custom format string.
@[JSON::Field(converter: Time::EpochConverter, type: "integer", format: "Int64")]
getter time : Time
# or if you just want to provide a custom format
@[JSON::Field(format: "email")]
getter email : String
end
```
for anything too confusing it falls back to a generic `{ type: "object" }` however this should only happen in some cases where you've inherited generic objects. e.g. `class Me < Hash(String, Int32)` (although this case is handled correctly)
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.2.0- Tagged
- Jun 14, 2026
- Commit
9b16a3cebffe- Indexed
- not yet
Dependents
Repository
github.com/spider-gazelle/json-schema
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 11