jsonschema

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2022 License: MIT Imports: 6 Imported by: 1

README

jsonschema Go Documentation Travis Go Report Card codecov

tenntenn/jsonschema is JSONSchema generator from Go types.

Install

Use go get:

$ go get github.com/tenntenn/jsonschema

Usage

All usage are described in GoDoc.

Documentation

Index

Constants

View Source
const (
	// RefRoot is root of JSON Schema reference.
	RefRoot = "#/"
)

Variables

This section is empty.

Functions

func Generate

func Generate(w io.Writer, v interface{}, opts ...Option) error

Generate generates JSON Schema from a Go type. Channel, complex, and function values cannot be encoded in JSON Schema. Attempting to generate such a type causes Generate to return an UnsupportedTypeError.

Types

type Generator

type Generator interface {
	JSONSchema(w io.Writer, opts ...Option) error
}

Generator generates a JSON Schema.

type Object

type Object interface {
	Set(key string, value interface{})
	Get(key string) (interface{}, bool)
	Ref() string
}

Object is interface of JSON object.

type Option

type Option func(o Object) (Object, error)

Option is options for JSON Schema.

func ByReference

func ByReference(pattern string, opt Option) Option

ByReference explicits refrence of adding option. It only supports refs which begins "#/".

func PropertyOrder

func PropertyOrder(order int) Option

PropertyOrder is add propertyOrder to schema.

func Ref

func Ref(ref string) Option

Ref replaces to given ref.

Directories

Path Synopsis
_example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL