jss-core

Crates.iojss-core
lib.rsjss-core
version0.2.0
sourcesrc
created_at2022-07-15 13:06:09.906958
updated_at2022-07-16 12:36:40.369678
descriptionJson Simplified Schema Core Interface
homepage
repositoryhttps://github.com/voml/jss
max_upload_size
id626195
size169,367
SasakiSaki (oovm)

documentation

https://docs.rs/jss-core

README

Json Schema Simplified

A better way to write schemas

Tools and Implement

Intellij

Rust

  • jss-rs
  • jss-cli: TODO
  • jss-mock: TODO

Node

Syntax

description

Aka. doc-comment, a comment starts with ///

schema

Top-level definitions, which specify constraints for all top-level fields

/// The description of OpenAPI v3.1.x documents without schema validation 
/// as defined by https://spec.openapis.org/oas/v3.1.0
schema _: object {
    $id: "https://spec.openapis.org/oas/3.0/schema/2021-09-28"
    $schema: "http://json-schema.org/draft-04/schema#"
    additionalProperties: false
    patternProperties: {
        "^x-": {},
    }
    required: [
        "openapi",
        "info",
        "paths",
    ]
}
Equivalent json schema
{
    "title": "_",
    "type": "object",
    "description": "The description of OpenAPI v3.1.x documents without schema validation\nas defined by https://spec.openapis.org/oas/v3.1.0",
    "$id": "https://spec.openapis.org/oas/3.0/schema/2021-09-28",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "additionalProperties": false,
    "patternProperties": {
        "^x-": {}
    },
    "required": [
        "openapi",
        "info",
        "paths"
    ],
    "properties": {}
}

define

Top-level definition, which specifies all references

define License: object {
    additionalProperties: false
    required: [
        "name",
    ]
    patternProperties: {
        "^x-": {},
    }
    .name: string
    .url: string {
        format: "uri-reference"
    }
}
Equivalent json schema
{
    "title": "_",
    "type": "undefined",
    "$defs": {
        "License": {
            "type": "object",
            "additionalProperties": false,
            "required": [
                "name"
            ],
            "patternProperties": {
                "^x-": {}
            },
            "$defs": {},
            "properties": {
                "name": {
                    "type": "string",
                    "properties": {}
                },
                "url": {
                    "type": "string",
                    "format": "uri-reference",
                    "properties": {}
                }
            }
        }
    },
    "properties": {}
}

property

Recursive definition, specifying the properties of each item

property can be abbreviated as .

/// Dimensions for the product
property dimensions: object {
    .length: number
    .width: number
    .height: number

    required: ["length", "width", "height"]
}
Equivalent json schema
{
    "title": "_",
    "type": "undefined",
    "properties": {
        "dimensions": {
            "type": "object",
            "description": "Dimensions for the product",
            "required": [
                "length",
                "width",
                "height"
            ],
            "properties": {
                "length": {
                    "type": "number",
                    "$defs": {},
                    "properties": {}
                },
                "width": {
                    "type": "number",
                    "properties": {}
                },
                "height": {
                    "type": "number",
                    "properties": {}
                }
            }
        }
    }
}

Evolution

  • CLI Tools
  • Mock data generator based on jss
Commit count: 64

cargo fmt