schema

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAllSchemas

func LoadAllSchemas(entryFiles []string) (map[string]*Schema, error)

LoadAllSchemas loads all entry schemas and recursively loads all referenced schemas.

Types

type Extensions

type Extensions struct {
	GoType       *string       `json:"x-go-type"`
	GoTypeImport *GoTypeImport `json:"x-go-type-import"`
	GoName       *string       `json:"x-go-name"`
	GoTypeName   *string       `json:"x-go-type-name"`
}

type GoTypeImport

type GoTypeImport struct {
	Path string `json:"path"`
	Name string `json:"name"`
}

type NamedSchema added in v0.2.0

type NamedSchema struct {
	Name   string
	Ref    string
	Schema *Schema
}

NamedSchema is a reusable schema declared in $defs or definitions.

type Schema

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

Schema represents a JSON Schema in a language-agnostic way.

func LoadSchema

func LoadSchema(filename string) (*Schema, error)

LoadSchema loads a JSON or YAML schema file and parses it into a *Schema model.

func (*Schema) Extensions

func (s *Schema) Extensions() (*Extensions, error)

func (*Schema) GetImportExtension

func (s *Schema) GetImportExtension() (path, name string, exists bool)

GetImportExtension retrieves import information from x-go-type-import extension. Returns path and name if the extension exists and is properly formatted.

func (*Schema) HasProperties

func (s *Schema) HasProperties() bool

HasProperties returns true if the schema has properties (is an object with properties).

func (*Schema) IsObject

func (s *Schema) IsObject() bool

IsObject returns true if the schema represents an object type.

func (*Schema) IsPropertyRequired

func (s *Schema) IsPropertyRequired(propName string) bool

IsPropertyRequired returns true if a property is required.

func (*Schema) Items

func (s *Schema) Items() *Schema

Items returns the schema for array items.

func (*Schema) Location

func (s *Schema) Location() string

Location returns the schema location.

func (*Schema) OrderedDefinitions added in v0.2.0

func (s *Schema) OrderedDefinitions() iter.Seq[NamedSchema]

OrderedDefinitions returns the schema definitions sorted by name and reference.

func (*Schema) OrderedProperties

func (s *Schema) OrderedProperties() iter.Seq2[string, *Schema]

func (*Schema) Properties

func (s *Schema) Properties() map[string]*Schema

Properties returns the schema properties.

func (*Schema) Ref

func (s *Schema) Ref() string

Ref returns the schema reference.

func (*Schema) RefSchema

func (s *Schema) RefSchema() *Schema

func (*Schema) Required

func (s *Schema) Required() []string

Required returns the list of required property names.

func (*Schema) Type

func (s *Schema) Type() string

Type returns the schema type.

Jump to

Keyboard shortcuts

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