generator

package
v0.0.0-...-4d3e907 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSchemaGenerator

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

JSONSchemaGenerator is the thing that generates schemas. This should not be created manually, instead use NewJSONSchemaGenerator(...)

func NewJSONSchemaGenerator

func NewJSONSchemaGenerator(basePackage, rootType string, options Options) *JSONSchemaGenerator

NewJSONSchemaGenerator creates an instance of the generator. basePackage is the package where the root schema object lives. rootType is the name of the type/struct ib the basePackage that represents the schema root.

func (*JSONSchemaGenerator) Generate

func (g *JSONSchemaGenerator) Generate() (schema.JSONSchema, error)

Generate is the main function that is used to generate a JSONSchema.

func (*JSONSchemaGenerator) LogDebug

func (g *JSONSchemaGenerator) LogDebug(args ...interface{})

LogDebug writes a debug message to std out

func (*JSONSchemaGenerator) LogDebugF

func (g *JSONSchemaGenerator) LogDebugF(format string, args ...interface{})

LogDebugF writes a debug formatted message to std out

func (*JSONSchemaGenerator) LogInfo

func (g *JSONSchemaGenerator) LogInfo(args ...interface{})

LogInfo writes an info message to std out

func (*JSONSchemaGenerator) LogInfoF

func (g *JSONSchemaGenerator) LogInfoF(format string, args ...interface{})

LogInfoF writes an info formatted message to std out

func (*JSONSchemaGenerator) LogVerbose

func (g *JSONSchemaGenerator) LogVerbose(args ...interface{})

LogVerbose writes a verbose message to std out

func (*JSONSchemaGenerator) LogVerboseF

func (g *JSONSchemaGenerator) LogVerboseF(format string, args ...interface{})

LogVerboseF writes a verbose formatted message to std out

func (*JSONSchemaGenerator) SubGenerate

func (g *JSONSchemaGenerator) SubGenerate(basePackage, rootType string) (schema.JSONSchema, error)

SubGenerate can be used to generate sub schemas after the main root has been generated.

type LogLevel

type LogLevel uint8

LogLevel is an enum specifying log verbosity

const (
	// QuietLevel level. Makes everything silent.
	QuietLevel LogLevel = iota
	// InfoLevel level.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. chatty logging.
	DebugLevel
	// VerboseLevel level. Usually only enabled when debugging. Very verbose logging.
	VerboseLevel
)

type Options

type Options struct {
	// SpecVersion is the url of the spec version
	SpecVersion schema.SpecVersion
	// IncludeTests will parse test files during generation when set to true or ignore them when false.
	IncludeTests bool
	// AutoCreateDefs will automatically create definitions when set to true. If false, schemas will be
	// included inline unless the 'definition' attribute is set within an @jsonSchema annotation
	AutoCreateDefs bool
	// LogLevel sets the verbosity of log statements
	LogLevel LogLevel
	// DefinitionPrefix is an optional prefix that will get pre-pended to all definition refs after the definition root.
	DefinitionPrefix string
	// SupressXAttrs is a flag ti supress non-standard schema properties like x-*
	SupressXAttrs bool
}

Options holds the configuration options for the schema generator instance

func NewOptions

func NewOptions() Options

NewOptions creates a new options instance with sane defaults.

Jump to

Keyboard shortcuts

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