transformer

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

type Default struct{}

Default is the default Transformer.

func (*Default) AddPathComments

func (d *Default) AddPathComments(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

AddPathComments adds additional comments such as parameters or responses to paths and their operations.

func (*Default) AddTags

func (d *Default) AddTags(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

AddTags adds tags that were given in the options or automatic tags if they are enabled.

func (*Default) DefaultOptions

func (d *Default) DefaultOptions() interface{}

DefaultOptions implements Transformer

func (*Default) Description

func (d *Default) Description() string

Description implements Transformer

func (*Default) DescriptionMarkdown

func (d *Default) DescriptionMarkdown() string

DescriptionMarkdown implements DescriptionMarkdown

func (*Default) ExtractAllOfs

func (d *Default) ExtractAllOfs(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

ExtractAllOfs creates all the types for AllOfs. AllOfs are a special type, all of their content are basically embedded structs.

func (*Default) ExtractSchemas

func (d *Default) ExtractSchemas(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

ExtractSchemas extracts the nested schemas that need to be created. This only extracts schemas with a custom type, and leaves allOfs and such alone.

func (*Default) GenerateOperationNames

func (d *Default) GenerateOperationNames(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

GenerateOperationNames generates operation names if they don't already have one.

func (*Default) GeneratePathNames

func (d *Default) GeneratePathNames(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

GeneratePathNames generates path names if they don't already have one.

func (*Default) GenerateResponseNames

func (d *Default) GenerateResponseNames(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

GenerateResponseNames generates response names if they don't already have one.

func (*Default) Name

func (d *Default) Name() string

Name implements Transformer

func (*Default) OrderResources

func (d *Default) OrderResources(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

OrderResources orders all the spec resources in an alphabetical order.

func (*Default) SimplifyInlineSchemas

func (d *Default) SimplifyInlineSchemas(ctx context.Context, sp *spec.Spec, opts *DefaultOptions) error

SimplifyInlineSchemas simplifies inline schemas so that there will not be any attempts to create methods for them, and so on.

func (*Default) Transform

func (d *Default) Transform(ctx context.Context, rawOpts interface{}, sp *spec.Spec) error

Transform implements Transformer

type DefaultOptions

type DefaultOptions struct {
	Tags map[string][]string `yaml:"tags,omitempty" description:"Add additional tags to struct fields. Supports Go templating with sprig functions"`
}

DefaultOptions alters the behaviour of the code generator.

func (*DefaultOptions) MarshalYAML

func (d *DefaultOptions) MarshalYAML() (interface{}, error)

MarshalYAML implements YAML Marshaler.

type TagTemplateValues

type TagTemplateValues struct {
	Description string `description:"Description of the schema"`
	FieldName   string `description:"Name of the field"`
	Type        string `description:"Type of the field"`
}

TagTemplateValues contains values for tag templates.

type Transformer

type Transformer interface {
	common.DescriptionMarkdown

	// The name of the transformer.
	Name() string

	// A short description of the transformer.
	Description() string

	// DefaultOptions Returns the default options of the transformer, or nil if it has none.
	DefaultOptions() interface{}

	// Transform transforms the specification based on options.
	Transform(ctx context.Context, options interface{}, specification *spec.Spec) error
}

Transformer transforms a specification before code generation.

Jump to

Keyboard shortcuts

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