definition

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefPrefix is the JSON Schema prefix required in the definition map
	DefPrefix = "#/definitions/"
)

Variables

This section is empty.

Functions

func GetFieldTag

func GetFieldTag(field *ast.Field) reflect.StructTag

GetFieldTag gets the StructTag for a field

Types

type CommentInformation

type CommentInformation struct {
	SynthesizedComment string
	RemainingComment   string
}

CommentInformation holds information interpreted from a comment string

type Definition

type Definition struct {
	Ref                  string                 `json:"$ref,omitempty"`
	Items                *Definition            `json:"items,omitempty"`
	Required             []string               `json:"required,omitempty"`
	Properties           map[string]*Definition `json:"properties,omitempty"`
	PreferredOrder       []string               `json:"preferredOrder,omitempty"`
	AdditionalProperties interface{}            `json:"additionalProperties,omitempty"`
	Type                 string                 `json:"type,omitempty"`
	ContentEncoding      string                 `json:"contentEncoding,omitempty"`
	OneOf                []*Definition          `json:"oneOf,omitempty"`
	Description          string                 `json:"description,omitempty"`
	HTMLDescription      string                 `json:"x-intellij-html-description,omitempty"`
	KubernetesGvk        []*GroupVersionKind    `json:"x-kubernetes-group-version-kind,omitempty"`
	Default              interface{}            `json:"default,omitempty"`
	Examples             []string               `json:"examples,omitempty"`
	Enum                 []string               `json:"enum,omitempty"`

	PatternProperties map[string]*Definition `json:"patternProperties,omitempty"`
}

Definition represents a JSON Schema definition

type Generator

type Generator struct {
	Strict      bool
	Definitions map[string]*Definition
	Importer    importer.Importer

	// TagNamespace to select which tag to use (e.g. json, yaml)
	TagNamespace string

	// FromatRefName allows customization of the ref name
	FromatRefName RefNameFormatFunc
}

Generator can create definitions from Exprs

func (*Generator) CollectDefinitionsFromStruct

func (dg *Generator) CollectDefinitionsFromStruct(thisPkg, rootStruct string)

CollectDefinitionsFromStruct gets a complete definition for the root object

type GroupVersionKind

type GroupVersionKind struct {
	Group   string `json:"group"`
	Version string `json:"version"`
	Kind    string `json:"kind"`
}

type Meta

type Meta struct {
	Required bool
	NoDerive bool
}

type RefNameFormatFunc

type RefNameFormatFunc func(pkg, name string) string

type TypeParamDefAndValue

type TypeParamDefAndValue struct {
	Defs         *ast.FieldList // Defs can be nil until we discovered type definition
	TypePackages []string
	Types        []ast.Expr // Values are concrete types
}

func (*TypeParamDefAndValue) Subst

func (p *TypeParamDefAndValue) Subst(pkg string, in ast.Expr) (string, ast.Expr)

func (*TypeParamDefAndValue) Validate

func (p *TypeParamDefAndValue) Validate() error

Jump to

Keyboard shortcuts

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