jsonschema

package
v0.0.0-...-694ff2b Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCsv

func BuildCsv(request interface{}) []string

func BuildJsonschema

func BuildJsonschema(v interface{}, needRender bool) string

BuildJsonschema reflects to Schema from a value using the default Reflector

Types

type DefaultRender

type DefaultRender struct {
	Code    int         `json:"code" doc:"错误码"`
	Message string      `json:"message" doc:"错误信息"`
	Data    interface{} `json:"data" doc:"数据"`
}

type Definitions

type Definitions map[string]*Schema

type Reflector

type Reflector struct {

	// RequiredFromJSONSchemaTags will cause the Reflector to generate a schema
	// that requires any key tagged with `jsonschema:required`, overriding the
	// default of requiring any key *not* tagged with `json:,omitempty`.
	RequiredFromJSONSchemaTags bool

	// KeyNamer allows customizing of key names.
	// The default is to use the key's name as is, or the json tag if present.
	// If a json tag is present, KeyNamer will receive the tag's name as an argument, not the original key name.
	KeyNamer func(string) string
}

A Reflector reflects values into a Schema.

func (*Reflector) Reflect

func (r *Reflector) Reflect(v interface{}) *Schema

Reflect reflects to Schema from a value.

func (*Reflector) ReflectFromType

func (r *Reflector) ReflectFromType(t reflect.Type) *Schema

ReflectFromType generates root schema

type Schema

type Schema struct {
	Definitions       Definitions            `json:"$defs,omitempty"`
	OneOf             []*Schema              `json:"oneOf,omitempty"`
	Items             *Schema                `json:"items,omitempty"`
	Properties        *orderedmap.OrderedMap `json:"properties,omitempty"`
	PatternProperties map[string]*Schema     `json:"patternProperties,omitempty"`
	Type              string                 `json:"type,omitempty"`
	Required          []string               `json:"required,omitempty"`
	Format            string                 `json:"format,omitempty"`
	ContentEncoding   string                 `json:"contentEncoding,omitempty"`
	Title             string                 `json:"title,omitempty"`
	Description       string                 `json:"description,omitempty"`
}

func ReflectFromType

func ReflectFromType(t reflect.Type) *Schema

ReflectFromType generates root schema using the default Reflector

Jump to

Keyboard shortcuts

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