gensource

package
v0.0.0-...-36f0857 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GitCommit string
	GitTag    string
	EsVersion string
)

Functions

This section is empty.

Types

type Body

type Body struct {
	Endpoint *Endpoint `json:"-"`

	Description string `json:"description"`
	Required    bool   `json:"required"`
	ContentType string `json:"serialize"`
}

Body represents API endpoint body.

type Command

type Command struct {
	Input          string
	Output         string
	Gofmt          bool
	DebugInfo      bool
	DebugSource    bool
	ColorizeSource bool
}

Command represents the "gensource" command.

func (*Command) Execute

func (cmd *Command) Execute() (err error)

Execute runs the command.

type Endpoint

type Endpoint struct {
	Name string `json:"-"`
	Type string `json:"-"`

	Documentation struct {
		URL         string `json:"url"`
		Description string `json:"description"`
	} `json:"documentation"`

	Stability string `json:"stability"`

	URL    *URL              `json:"url"`
	Params map[string]*Param `json:"params"`
	Body   *Body             `json:"body"`
}

Endpoint represents an API endpoint.

func NewEndpoint

func NewEndpoint(f io.Reader) (*Endpoint, error)

NewEndpoint creates a new API endpoint.

func (*Endpoint) DebugInfo

func (e *Endpoint) DebugInfo() string

DebugInfo returns information about the endpoint as a string.

func (*Endpoint) HumanMethodWithNamespace

func (e *Endpoint) HumanMethodWithNamespace() string

HumanMethodWithNamespace returns the API endpoint method name in humanized form.

func (*Endpoint) MethodName

func (e *Endpoint) MethodName() string

MethodName returns the API endpoint method name.

func (*Endpoint) MethodWithNamespace

func (e *Endpoint) MethodWithNamespace() string

MethodWithNamespace returns the API endpoint method name with namespace.

func (*Endpoint) Namespace

func (e *Endpoint) Namespace() string

Namespace returns the API endpoint namespace.

func (*Endpoint) RequiredArguments

func (e *Endpoint) RequiredArguments() []MethodArgument

RequiredArguments return the list of required method arguments.

type Generator

type Generator struct {
	Endpoint *Endpoint
	// contains filtered or unexported fields
}

Generator represents the "gensource" generator.

func (*Generator) GetOverride

func (g *Generator) GetOverride(id, apiName string) OverrideFunc

GetOverride returns an override function for id and API name.

func (*Generator) Output

func (g *Generator) Output() (io.Reader, error)

Output returns the generator output.

func (*Generator) OutputFormatted

func (g *Generator) OutputFormatted() (io.Reader, error)

OutputFormatted returns a formatted generator output.

type MethodArgument

type MethodArgument struct {
	Endpoint *Endpoint

	Name        string
	Type        string
	Description string
	Options     []string
	Default     interface{}
	Required    bool
}

MethodArgument represents a method argument for API endpoint.

func (*MethodArgument) GoName

func (p *MethodArgument) GoName() string

GoName returns a Go name for method argument.

func (*MethodArgument) GoType

func (p *MethodArgument) GoType(comment ...bool) string

GoType returns a Go type for method argument.

type OverrideFunc

type OverrideFunc func(*Endpoint, ...interface{}) string

OverrideFunc defines a function to override generated code for endpoint.

type OverrideRule

type OverrideRule struct {
	Func     OverrideFunc
	Matching []string
}

OverrideRule represents an override rule.

func (OverrideRule) Match

func (r OverrideRule) Match(apiName string) bool

Match returns true when API name matches a rule.

type Param

type Param struct {
	Endpoint *Endpoint `json:"-"`

	Name string `json:"-"`

	Type        string      `json:"type"`
	Description string      `json:"description"`
	Options     []string    `json:"options"`
	Default     interface{} `json:"default"`
	Required    bool        `json:"required"`
}

Param represents API endpoint parameter.

func (*Param) GoName

func (p *Param) GoName() string

GoName returns a Go name for parameter.

func (*Param) GoType

func (p *Param) GoType(comment ...bool) string

GoType returns a Go type for parameter.

type Part

type Part struct {
	Endpoint *Endpoint `json:"-"`

	Name    string      `json:"-"`
	Default interface{} `json:"-"`

	Type        string `json:"type"`
	Description string `json:"description"`
	Required    bool   `json:"required"`

	Deprecated bool `json:"deprecated"`
}

Part represents part of the API endpoint URL.

func (*Part) GoName

func (p *Part) GoName() string

GoName returns a Go name for part.

func (*Part) GoType

func (p *Part) GoType(comment ...bool) string

GoType returns a Go type for part.

type Path

type Path struct {
	Path       string           `json:"path"`
	Methods    []string         `json:"methods"`
	Parts      map[string]*Part `json:"parts"`
	Deprecated struct {
		Version     string `json:"version"`
		Description string `json:"description"`
	}
}

Path represents URL path

type URL

type URL struct {
	Endpoint *Endpoint `json:"-"`

	Paths           []Path `json:"paths"`
	DeprecatedPaths []struct {
		Path        string `json:"path"`
		Version     string `json:"version"`
		Description string `json:"description"`
	} `json:"deprecated_paths"`
	Params map[string]*Param `json:"params"`

	AllParts         map[string]*Part
	PartNamesSorted  []string
	ParamNamesSorted []string
}

URL represents API endpoint URL.

Jump to

Keyboard shortcuts

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