openapi

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "3.0.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Title       string `tag:"title"`
	Description string `tag:"description"`
	Min         int    `tag:"min"`
	Max         int    `tag:"max"`
	Items       Schema
	Default     []string `tag:"default"`
	Nullable    bool     `tag:"flags:nullable"`
	ReadOnly    bool     `tag:"flags:readonly"`
	WriteOnly   bool     `tag:"flags:writeonly"`
	UniqueItems bool     `tag:"flags:unique"`
}

func (*Array) GetTitle

func (sch *Array) GetTitle() string

func (*Array) Hash

func (sch *Array) Hash() uint64

type Boolean

type Boolean struct {
	Title       string `tag:"title"`
	Description string `tag:"description"`
	Default     string `tag:"default"`
	Nullable    bool   `tag:"flags:nullable"`
	ReadOnly    bool   `tag:"flags:readonly"`
	WriteOnly   bool   `tag:"flags:writeonly"`
}

func (*Boolean) GetTitle

func (sch *Boolean) GetTitle() string

func (*Boolean) Hash

func (sch *Boolean) Hash() uint64

type Contact

type Contact struct {
	Name  string
	Url   string
	Email string
}

func (*Contact) JsonEncode

func (c *Contact) JsonEncode(_ *encoderContext, s *jsoniter.Stream)

type Custom added in v0.10.0

type Custom struct {
	ContentType string
	Schema
}

type Document

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

func NewDocument

func NewDocument(info Info, servers ...Server) *Document

Create a new OpenAPI root document that is ready to be used in the API service.

func (*Document) AddSecurityScheme added in v0.7.0

func (doc *Document) AddSecurityScheme(scheme SecurityScheme) (err error)

func (*Document) JsonEncode

func (doc *Document) JsonEncode(s *jsoniter.Stream) (err error)

func (*Document) NumOperations

func (doc *Document) NumOperations() int

type Info

type Info struct {
	Title          string
	Description    string
	TermsOfService string
	Contact        Contact
	License        License
	Version        string
}

func (*Info) JsonEncode

func (i *Info) JsonEncode(ctx *encoderContext, s *jsoniter.Stream)

type Integer

type Integer[T constraints.Integer] struct {
	Title       string `tag:"title"`
	Description string `tag:"description"`
	Min         T      `tag:"min"`
	Max         T      `tag:"max"`
	Default     string `tag:"default"`
	Nullable    bool   `tag:"flags:nullable"`
	ReadOnly    bool   `tag:"flags:readonly"`
	WriteOnly   bool   `tag:"flags:writeonly"`
}

func (*Integer[T]) GetTitle

func (sch *Integer[T]) GetTitle() string

func (*Integer[T]) Hash

func (sch *Integer[T]) Hash() uint64

type License

type License struct {
	Name       string
	Identifier string
	Url        string
}

func (*License) JsonEncode

func (l *License) JsonEncode(_ *encoderContext, s *jsoniter.Stream)

type Number

type Number[T constraints.Float] struct {
	Title       string `tag:"title"`
	Description string `tag:"description"`
	Min         T      `tag:"min"`
	Max         T      `tag:"max"`
	Default     string `tag:"default"`
	Nullable    bool   `tag:"flags:nullable"`
	ReadOnly    bool   `tag:"flags:readonly"`
	WriteOnly   bool   `tag:"flags:writeonly"`
}

func (*Number[T]) GetTitle

func (sch *Number[T]) GetTitle() string

func (*Number[T]) Hash

func (sch *Number[T]) Hash() uint64

type Object

type Object struct {
	Title       string `tag:"title"`
	Description string `tag:"description"`
	Required    []string
	Properties  []ObjectProperty
	Nullable    bool `tag:"flags:nullable"`
	ReadOnly    bool `tag:"flags:readonly"`
	WriteOnly   bool `tag:"flags:writeonly"`
}

func (*Object) GetTitle

func (sch *Object) GetTitle() string

func (*Object) Hash

func (sch *Object) Hash() uint64

type ObjectProperty

type ObjectProperty struct {
	Name   string
	Schema Schema
}

type Operation

type Operation struct {
	Id          string
	Method      string
	Summary     string
	Description string
	Security    []SecurityRequirement
	Parameters  []Parameter
	RequestBody Schema
	Response    Schema
	Tags        []Tag
}

func (*Operation) JsonEncode

func (op *Operation) JsonEncode(ctx *encoderContext, s *jsoniter.Stream)

type Parameter

type Parameter struct {
	Name        string
	In          ParameterIn
	Description string
	Schema      Schema
	Required    bool
}

func (*Parameter) JsonEncode

func (p *Parameter) JsonEncode(ctx *encoderContext, s *jsoniter.Stream)

type ParameterIn

type ParameterIn string
const (
	InQuery  ParameterIn = "query"
	InHeader ParameterIn = "header"
	InPath   ParameterIn = "path"
	InCookie ParameterIn = "cookie"
)

func (ParameterIn) JsonEncode

func (p ParameterIn) JsonEncode(_ *encoderContext, s *jsoniter.Stream)

func (ParameterIn) String

func (p ParameterIn) String() string

type Paths

type Paths map[string][]*Operation

func (Paths) AddOperation

func (p Paths) AddOperation(path string, op *Operation) (err error)

func (Paths) JsonEncode

func (p Paths) JsonEncode(ctx *encoderContext, s *jsoniter.Stream)

type Ref

type Ref struct {
	Name   string
	Schema Schema
}

func (*Ref) GetTitle

func (sch *Ref) GetTitle() string

func (*Ref) Hash

func (sch *Ref) Hash() uint64

type Schema

type Schema interface {
	hasher.Hashable
	GetTitle() string
	// contains filtered or unexported methods
}

type SecurityRequirement added in v0.7.0

type SecurityRequirement struct {
	Name   string
	Scopes []string
}

func (SecurityRequirement) IsZero added in v0.7.0

func (sec SecurityRequirement) IsZero() bool

func (SecurityRequirement) JsonEncode added in v0.7.0

func (ss SecurityRequirement) JsonEncode(s *jsoniter.Stream)

type SecurityScheme added in v0.7.0

type SecurityScheme struct {
	SchemeName       string
	Type             string
	Description      string
	Name             string
	In               string
	Scheme           string
	BearerFormat     string
	Flows            struct{} // TODO
	OpenIdConnectUrl struct{} // TODO
}

func (*SecurityScheme) IsZero added in v0.7.0

func (sec *SecurityScheme) IsZero() bool

func (*SecurityScheme) JsonEncode added in v0.7.0

func (sec *SecurityScheme) JsonEncode(s *jsoniter.Stream)

type Server

type Server struct {
	Description string
	Url         string
}

func (*Server) JsonEncode

func (serv *Server) JsonEncode(_ *encoderContext, s *jsoniter.Stream)

type String

type String struct {
	Title       string   `tag:"title"`
	Description string   `tag:"description"`
	Enum        []string `tag:"enum"`
	Format      string   `tag:"format"`
	Pattern     string   `tag:"pattern"`
	Min         int      `tag:"min"`
	Max         int      `tag:"max"`
	Default     string   `tag:"default"`
	Nullable    bool     `tag:"flags:nullable"`
	ReadOnly    bool     `tag:"flags:readonly"`
	WriteOnly   bool     `tag:"flags:writeonly"`
}

func (*String) GetTitle

func (sch *String) GetTitle() string

func (*String) Hash

func (sch *String) Hash() uint64

type Tag

type Tag struct {
	Name        string
	Description string
}

func NewTag

func NewTag(name string, description ...string) Tag

func (*Tag) JsonEncode

func (t *Tag) JsonEncode(_ *encoderContext, s *jsoniter.Stream)

Jump to

Keyboard shortcuts

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