opendoc

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape added in v0.0.5

func Escape(token string) string

Escape escapes a pointer reference token string

func GetCanonicalTypeName added in v0.0.5

func GetCanonicalTypeName(val interface{}) string

func ToRESTFriendlyName added in v0.0.5

func ToRESTFriendlyName(name string) string

ToRESTFriendlyName converts Golang package/type canonical name into REST friendly OpenAPI name.

Examples of REST friendly OpenAPI name:

Input:  k8s.io/api/core/v1.Pod
Output: io.k8s.api.core.v1.Pod

Input:  k8s.io/api/core/v1
Output: io.k8s.api.core.v1

Input:  csi.storage.k8s.io/v1alpha1.CSINodeInfo
Output: io.k8s.storage.csi.v1alpha1.CSINodeInfo

Copy from k8s.io/kube-openapi

func Unescape added in v0.0.5

func Unescape(token string) string

Unescape unescapes a json pointer reference token string to the original representation

Types

type AllOfExposer added in v0.0.4

type AllOfExposer interface {
	JSONSchemaAllOf() []interface{}
}

AllOfExposer exposes "allOf" items as list of samples.

type AnyOfExposer added in v0.0.4

type AnyOfExposer interface {
	JSONSchemaAnyOf() []interface{}
}

AnyOfExposer exposes "anyOf" items as list of samples.

type Config

type Config struct {
	Title                string                 `yaml:"title"`
	OpenapiRouter        string                 `yaml:"path"`
	OpenapiRedocRouter   string                 `yaml:"redoc-path"`
	OpenapiRApiDocRouter string                 `yaml:"rapidoc-path"`
	OpenapiUrl           string                 `yaml:"openapi-path"`
	OpenapiOpt           map[string]interface{} `yaml:"options"`
}

func DefaultCfg

func DefaultCfg() *Config

type Contact

type Contact = openapi3.Contact

type ElseExposer added in v0.0.4

type ElseExposer interface {
	JSONSchemaElse() interface{}
}

ElseExposer exposes "else" schema as a sample.

type Enum added in v0.0.4

type Enum interface {
	Enum() []interface{}
}

Enum returns the enumerated acceptable values.

type IfExposer added in v0.0.4

type IfExposer interface {
	JSONSchemaIf() interface{}
}

IfExposer exposes "if" schema as a sample.

type License

type License = openapi3.License

type NamedEnum added in v0.0.4

type NamedEnum interface {
	NamedEnum() ([]interface{}, []string)
}

NamedEnum returns the enumerated acceptable values with according string names.

type NotExposer added in v0.0.4

type NotExposer interface {
	JSONSchemaNot() interface{}
}

NotExposer exposes "not" schema as a sample.

type OneOfExposer added in v0.0.4

type OneOfExposer interface {
	JSONSchemaOneOf() []interface{}
}

OneOfExposer exposes "oneOf" items as list of samples.

type Operation

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

func (*Operation) AddResponse added in v0.0.4

func (op *Operation) AddResponse(name string, resp interface{}) *Operation

func (*Operation) AddSecurity

func (op *Operation) AddSecurity(security ...security.Security) *Operation

func (*Operation) Openapi

func (op *Operation) Openapi(item *openapi3.PathItem)

func (*Operation) SetDescription

func (op *Operation) SetDescription(description string) *Operation

func (*Operation) SetExclude added in v0.0.4

func (op *Operation) SetExclude(exclude bool) *Operation

func (*Operation) SetModel

func (op *Operation) SetModel(req, rsp interface{}) *Operation

func (*Operation) SetOperation added in v0.0.4

func (op *Operation) SetOperation(operationID string) *Operation

func (*Operation) SetPath

func (op *Operation) SetPath(path string) *Operation

func (*Operation) SetSummary

func (op *Operation) SetSummary(summary string) *Operation

type Server

type Server = openapi3.Server

type Servers

type Servers = openapi3.Servers

type Service

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

func (*Service) AddContentType

func (s *Service) AddContentType(contentType ...string) *Service

func (*Service) AddSecurity

func (s *Service) AddSecurity(security ...security.Security) *Service

func (*Service) DeleteOf

func (s *Service) DeleteOf(cb func(op *Operation)) *Service

func (*Service) GetOf

func (s *Service) GetOf(cb func(op *Operation)) *Service

func (*Service) Openapi

func (s *Service) Openapi() map[string]*openapi3.PathItem

func (*Service) PatchOf

func (s *Service) PatchOf(cb func(op *Operation)) *Service

func (*Service) PostOf

func (s *Service) PostOf(cb func(op *Operation)) *Service

func (*Service) PutOf

func (s *Service) PutOf(cb func(op *Operation)) *Service

func (*Service) SetName added in v0.0.4

func (s *Service) SetName(name string) *Service

func (*Service) SetPrefix

func (s *Service) SetPrefix(prefix string) *Service

type Swagger

type Swagger struct {
	Config         *Config
	Description    string
	Version        string
	TermsOfService string
	Routers        []*Service
	Servers        openapi3.Servers
	Contact        *openapi3.Contact
	License        *openapi3.License
	// contains filtered or unexported fields
}

func New

func New(handles ...func(swag *Swagger)) *Swagger

func (*Swagger) InitRouter

func (s *Swagger) InitRouter(r *http.ServeMux)

func (*Swagger) MarshalJSON

func (s *Swagger) MarshalJSON() ([]byte, error)

func (*Swagger) MarshalYAML

func (s *Swagger) MarshalYAML() ([]byte, error)

func (*Swagger) OpenapiDataHandler

func (s *Swagger) OpenapiDataHandler() http.HandlerFunc

func (*Swagger) ServiceOf

func (s *Swagger) ServiceOf(name string, cb func(srv *Service))

func (*Swagger) SetRootPath

func (s *Swagger) SetRootPath(path string)

func (*Swagger) WithService added in v0.0.4

func (s *Swagger) WithService() *Service

type ThenExposer added in v0.0.4

type ThenExposer interface {
	JSONSchemaThen() interface{}
}

ThenExposer exposes "then" schema as a sample.

Jump to

Keyboard shortcuts

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