swaggergen

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const OpenApiVersion = "3.0.0"

Variables

This section is empty.

Functions

func InterfaceToType

func InterfaceToType(data interface{}) string

Types

type Content

type Content struct {
	Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
}

Content represents a content in the spec

func NewContent

func NewContent(res *http.Response) *Content

NewContent creates a new content

func (*Content) UpdateContent

func (c *Content) UpdateContent(res *http.Response)

UpdateContent updates a content

type Info

type Info struct {
	Title       string `json:"title,omitempty" yaml:"title,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Version     string `json:"version,omitempty" yaml:"version,omitempty"`
}

func NewInfo

func NewInfo(title string) *Info

NewInfo creates a new info

func (*Info) UpdateInfo

func (i *Info) UpdateInfo(title string)

UpdateInfo updates a info

type Method

type Method struct {
	Summary    string            `json:"summary,omitempty" yaml:"summary,omitempty"`
	Responses  map[int]*Response `json:"responses,omitempty" yaml:"responses,omitempty"`
	Parameters []*Parameter      `json:"parameters,omitempty" yaml:"parameters,omitempty"`
}

Operation represents an operation in the spec

func NewMethod

func NewMethod(reqRes RequestResponse) *Method

NewMethod creates a new method

func (*Method) UpdateMethod

func (m *Method) UpdateMethod(reqRes RequestResponse)

UpdateMethod updates a method

type Parameter

type Parameter struct {
	Name        string  `json:"name,omitempty" yaml:"name,omitempty"`
	In          string  `json:"in,omitempty" yaml:"in,omitempty"`
	Description string  `json:"description,omitempty" yaml:"description,omitempty"`
	Required    bool    `json:"required,omitempty" yaml:"required,omitempty"`
	Schema      *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
}

Parameter represents a parameter in the spec

func NewParameters

func NewParameters(req *http.Request) []*Parameter

NewParameters creates a new parameters

type Path

type Path map[string]*Method

Path represents a path in the spec

func NewPath

func NewPath(reqRes RequestResponse) Path

NewPath creates a new path

func (Path) UpdatePath

func (p Path) UpdatePath(reqRes RequestResponse)

UpdatePath updates a path

type RequestResponse

type RequestResponse struct {
	Request  *http.Request
	Response *http.Response
}

RequestResponse represents a request and response

type Response

type Response struct {
	Description string              `json:"description,omitempty" yaml:"description,omitempty"`
	Content     map[string]*Content `json:"content,omitempty" yaml:"content,omitempty"`
}

Response represents a response in the spec

func NewResponse

func NewResponse(res *http.Response) *Response

NewResponse creates a new response

func (*Response) UpdateResponse

func (r *Response) UpdateResponse(res *http.Response)

UpdateResponse updates a response

type Schema

type Schema struct {
	Type        string             `json:"type" yaml:"type"`
	Properties  map[string]*Schema `json:"properties,omitempty" yaml:"properties,omitempty"`
	Description string             `json:"description" yaml:"description,omitempty"`
}

Schema represents a schema in the spec

func NewSchema

func NewSchema(reader io.Reader) *Schema

type Server

type Server struct {
	URL         string `json:"url,omitempty" yaml:"url,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

func NewServer

func NewServer(url, description string) *Server

NewServer creates a new server

type Spec

type Spec struct {
	OpenApi string          `json:"openapi"`
	Info    *Info           `json:"info"`
	Servers []*Server       `json:"servers"`
	Paths   map[string]Path `json:"paths"`
}

Spec represents openapi 3 specification

func NewSpec

func NewSpec(logDir, api string) *Spec

NewSpec creates a new spec

func (*Spec) AddPath

func (s *Spec) AddPath(reqRes RequestResponse)

AddPath adds a path to the spec

func (*Spec) UpdateSpec

func (s *Spec) UpdateSpec(logDir, api string)

UpdateSpec updates a spec

Jump to

Keyboard shortcuts

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