Documentation ¶
Index ¶
- Variables
- func Load(location string) (io.ReadCloser, error)
- func RegisterLoader(loader Loader, schemes ...string)
- func UnregisterLoader(scheme string)
- func WordSequence(words []string, separator string) string
- type Any
- type CachedLoader
- type Context
- type FileLoader
- type HTTPLoader
- type Loader
- type Schema
- func (s *Schema) BaseURI() *url.URL
- func (s *Schema) Clone() (*Schema, error)
- func (s *Schema) DescriptionMarkdown() string
- func (s *Schema) EnsureDocument()
- func (s *Schema) EntityLink() string
- func (s *Schema) EntityName() string
- func (s *Schema) EnumMarkdownItems() []string
- func (s *Schema) GenPath() string
- func (s *Schema) Merge(other *Schema)
- func (s *Schema) RefURI(ref string) *url.URL
- func (s *Schema) RequiredKey(key string) bool
- func (s *Schema) Root() *Schema
- func (s *Schema) TypeInfo() []TypeInfo
- func (s *Schema) TypeInfoMarkdown() string
- func (s *Schema) YAMLExamples() []string
- type Type
- type TypeInfo
- type Types
Constants ¶
This section is empty.
Variables ¶
var Templates embed.FS
Functions ¶
func Load ¶
func Load(location string) (io.ReadCloser, error)
Load loads the content from location using the appropriate Loader.
func RegisterLoader ¶
RegisterLoader registers a loader for the given schemes.
func UnregisterLoader ¶
func UnregisterLoader(scheme string)
UnregisterLoader unregisters the loader for the given scheme.
func WordSequence ¶
Types ¶
type Any ¶
type Any struct {
// contains filtered or unexported fields
}
func (Any) JSONString ¶ added in v0.5.0
func (Any) MarshalJSON ¶
func (*Any) UnmarshalJSON ¶
func (Any) YAMLString ¶ added in v0.5.0
type CachedLoader ¶
type CachedLoader struct {
// contains filtered or unexported fields
}
CachedLoader caches the results of another Loader in-memory.
func NewCachedLoader ¶
func NewCachedLoader(loader Loader) *CachedLoader
NewCachedLoader wraps the given loader with one that caches results in-memory.
func (*CachedLoader) Load ¶
func (l *CachedLoader) Load(uri *url.URL) (io.ReadCloser, error)
Load delegates to the wrapped loader and caches the result.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext() *Context
type FileLoader ¶
type FileLoader struct { }
FileLoader loads files from the filesystem.
func (*FileLoader) Load ¶
func (l *FileLoader) Load(uri *url.URL) (io.ReadCloser, error)
Load opens the given URI.
type HTTPLoader ¶
type HTTPLoader struct {
// contains filtered or unexported fields
}
HTTPLoader loads files via net/http.
func NewHTTPLoader ¶
func NewHTTPLoader(client *http.Client) *HTTPLoader
NewHTTPLoader returns a new HTTPLoader.
func (*HTTPLoader) Load ¶
func (l *HTTPLoader) Load(uri *url.URL) (io.ReadCloser, error)
Load requests the given URI via HTTP GET.
type Loader ¶
type Loader interface { // Load returns an [io.ReadCloser] for the content at the given URI. Load(uri *url.URL) (io.ReadCloser, error) }
Loader is a type that can load schemas from a URI.
func RegisteredLoader ¶
RegisteredLoader returns the loader registered for a scheme.
type Schema ¶
type Schema struct { AdditionalItems *Schema `json:"additionalItems,omitempty"` AdditionalProperties any `json:"additionalProperties,omitempty"` AllOf []*Schema `json:"allOf,omitempty"` AnyOf []*Schema `json:"anyOf,omitempty"` Comment string `json:"$comment,omitempty"` Const Any `json:"const,omitempty"` Contains *Schema `json:"contains,omitempty"` ContentEncoding string `json:"contentEncoding,omitempty"` ContentMediaType string `json:"contentMediaType,omitempty"` Default Any `json:"default,omitempty"` Definitions map[string]*Schema `json:"definitions,omitempty"` Deprecated bool `json:"deprecated,omitempty"` Description string `json:"description,omitempty"` Else *Schema `json:"else,omitempty"` Enum []Any `json:"enum,omitempty"` EnumDescriptions []string `json:"enumDescriptions,omitempty"` Examples []Any `json:"examples,omitempty"` ExclusiveMaximum float64 `json:"exclusiveMaximum,omitempty"` ExclusiveMinimum float64 `json:"exclusiveMinimum,omitempty"` Format string `json:"format,omitempty"` ID string `json:"$id,omitempty"` If *Schema `json:"if,omitempty"` Items *Schema `json:"items,omitempty"` MarkdownDescription string `json:"markdownDescription,omitempty"` MaxContains int `json:"maxContains,omitempty"` Maximum float64 `json:"maximum,omitempty"` MaxItems int `json:"maxItems,omitempty"` MaxLength int `json:"maxLength,omitempty"` MaxProperties int `json:"maxProperties,omitempty"` MinContains int `json:"minContains,omitempty"` Minimum float64 `json:"minimum,omitempty"` MinItems int `json:"minItems,omitempty"` MinLength int `json:"minLength,omitempty"` MinProperties int `json:"minProperties,omitempty"` MultipleOf float64 `json:"multipleOf,omitempty"` Not []*Schema `json:"not,omitempty"` OneOf []*Schema `json:"oneOf,omitempty"` Pattern string `json:"pattern,omitempty"` PatternProperties map[string]*Schema `json:"patternProperties,omitempty"` PrefixItems []*Schema `json:"prefixItems,omitempty"` Properties map[string]*Schema `json:"properties,omitempty"` PropertyNames *Schema `json:"propertyNames,omitempty"` ReadOnly bool `json:"readOnly,omitempty"` Ref string `json:"$ref,omitempty"` Required []string `json:"required,omitempty"` Schema string `json:"$schema,omitempty"` Then *Schema `json:"then,omitempty"` Title string `json:"title,omitempty"` Types Types `json:"type,omitempty"` UnevaluatedProperties bool `json:"unevaluatedProperties,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` WriteOnly bool `json:"writeOnly,omitempty"` Context *Context `json:"-"` Document any `json:"-"` GenPathTpl render.Template `json:"-"` Key string `json:"key,omitempty"` Parent *Schema `json:"-"` Resolved bool `json:"resolved,omitempty"` RetrievalURI string `json:"retrievalURI,omitempty"` }
Schema represents a JSON schema document.
func (*Schema) BaseURI ¶
BaseURI returns the resolved base URI for the schema. The base URI is the schema $id attribute resolved against the retrieval URI.
func (*Schema) DescriptionMarkdown ¶ added in v0.4.0
DescriptionMarkdown returns the schema description formatted as Markdown, Will prioritize the non-standard `markdownDescription` attribute if present, otherwise uses `description`.
func (*Schema) EnsureDocument ¶
func (s *Schema) EnsureDocument()
func (*Schema) EntityLink ¶
func (*Schema) EntityName ¶
func (*Schema) EnumMarkdownItems ¶ added in v0.6.0
EnumMarkdownItems returns the .Enum items formatted as Markdown. If .Const is present, will treat that as a virtual enum of one.
func (*Schema) RequiredKey ¶
RequiredKey returns true when key is a required property.
func (*Schema) TypeInfoMarkdown ¶
func (*Schema) YAMLExamples ¶ added in v0.6.0
YAMLExamples returns the examples formatted as YAML.