jschema

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 17 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserTypeNamesFromEachTypeConstraint added in v0.2.0

func UserTypeNamesFromEachTypeConstraint(node ischema.Node) []string

func UserTypeNamesFromTypeConstraint added in v0.2.0

func UserTypeNamesFromTypeConstraint(node ischema.Node) []string

func UserTypeNamesFromTypesListConstraint added in v0.2.0

func UserTypeNamesFromTypesListConstraint(node ischema.Node) []string

Types

type JSchema

type JSchema struct {
	File  *fs.File
	Inner *ischema.ISchema

	Rules map[string]schema.Rule

	// UserTypesNamesUsed the names of the USER TYPES mentioned in the schema.
	// They are collected from the schema when it is loaded.
	UserTypesNamesUsed *StringSet

	// UserTypeCollection is a list of added USER TYPES. Not all of them can actually be used in the schema.
	// Required for the OpenAPI converter.
	UserTypeCollection map[string]schema.Schema

	LenOnce     sync.ErrOnceWithValue[uint]
	LoadOnce    sync.ErrOnce
	CompileOnce sync.ErrOnce

	ASTNode                  schema.ASTNode
	AreKeysOptionalByDefault bool
}

func FromFile

func FromFile(f *fs.File, oo ...Option) *JSchema

FromFile creates a Jsight schema from file.

func FromRSchema added in v0.2.0

func FromRSchema(s *regex.RSchema) (*JSchema, error)

func New

func New[T bytes.ByteKeeper](name string, content T, oo ...Option) *JSchema

New creates a Jsight schema with specified name and content.

func (*JSchema) AddRule

func (s *JSchema) AddRule(n string, r schema.Rule) error

func (*JSchema) AddType

func (s *JSchema) AddType(name string, sc schema.Schema) (err error)

func (*JSchema) BuildASTNode

func (s *JSchema) BuildASTNode() schema.ASTNode

func (*JSchema) Check

func (s *JSchema) Check() (err error)

func (*JSchema) CollectUserTypes

func (s *JSchema) CollectUserTypes()

func (*JSchema) Compile

func (s *JSchema) Compile() error

func (*JSchema) Example

func (s *JSchema) Example() (b []byte, err error)

func (*JSchema) GetAST

func (s *JSchema) GetAST() (an schema.ASTNode, err error)

func (*JSchema) InnerTypesList

func (s *JSchema) InnerTypesList() map[string]ischema.Type

func (*JSchema) Len

func (s *JSchema) Len() (uint, error)

func (*JSchema) UsedUserTypes

func (s *JSchema) UsedUserTypes() ([]string, error)

type Option

type Option func(s *JSchema)

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

StringSet a set of strings. gen:Set

func NewStringSet

func NewStringSet(vv ...string) *StringSet

func (*StringSet) Add

func (m *StringSet) Add(v string)

Add adds specific value to set.

func (*StringSet) Data

func (m *StringSet) Data() []string

Data return set's data.

func (*StringSet) Has

func (m *StringSet) Has(v string) bool

Has checks that specified value is exists.

func (*StringSet) Len

func (m *StringSet) Len() int

Len returns len of set.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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