swaggerlt

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: Apache-2.0 Imports: 16 Imported by: 3

README

swaggerlt

Takes a swagger 2.0 spec and generates a golang client with minimal external dependencies.

Warning This is by no means completed yet. Use at your own risk.

Go Report Card

created by tigwen

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error added in v1.0.4

type Error struct {
	StatusCode int
	Body       any
}

func (*Error) Error added in v1.0.4

func (r *Error) Error() string

type Generator

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

func New

func New(options *Options) (*Generator, error)

func (*Generator) Execute

func (g *Generator) Execute() (err error)

type Imports

type Imports []string

func (*Imports) Add

func (i *Imports) Add(path string)

func (*Imports) Append

func (i *Imports) Append(imports *Imports)

func (*Imports) Code

func (i *Imports) Code() string

type Operation

type Operation struct {
	Path           string       `json:"path"`
	Verb           string       `json:"verb"`
	Tags           []string     `json:"tags"`
	Description    string       `json:"description"`
	Parameters     []*Parameter `json:"parameters,omitempty"`
	Responses      []*Response  `json:"responses,omitempty"`
	XOperationName string       `json:"x-operation-name"`
	RawData        []byte       `json:"-"`
}

func OperationFromSpec

func OperationFromSpec(path, verb string, value []byte) (op *Operation, err error)

type Options

type Options struct {
	PathRegex   *regexp.Regexp
	SpecFile    string
	ServiceName string
	ModuleName  string
}

type Parameter

type Parameter struct {
	Name        string `json:"name"`
	NameOrig    string `json:"name_orig"`
	In          string `json:"in"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Type        string `json:"type,omitempty"`
	Ref         string `json:"ref,omitempty"`
	Items       string `json:"items,omitempty"`
	ItemsRef    string `json:"itemsRef,omitempty"`
}

type RequestHelper

type RequestHelper struct {
	Endpoint      string
	Uri           string
	Method        string
	QueryValues   url.Values
	PathParam     map[string]string
	Headers       map[string]string
	ResponseTypes map[int]any
	Body          any
	Response      any
}

func NewRequestHelper

func NewRequestHelper(method, endpoint, uri string) *RequestHelper

func (*RequestHelper) Execute

func (u *RequestHelper) Execute(client *http.Client) (err error)

func (*RequestHelper) Header

func (u *RequestHelper) Header(name string, value string)

func (*RequestHelper) Param

func (u *RequestHelper) Param(name string, value any)

func (*RequestHelper) Path

func (u *RequestHelper) Path(name string, value string)

func (*RequestHelper) ResponseType added in v1.0.4

func (u *RequestHelper) ResponseType(code int, body any)

type Response

type Response struct {
	Code        int    `json:"code"`
	Description string `json:"description,omitempty"`
	Ref         string `json:"ref,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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