opendoc

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 17 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 any) string

func IsRequired added in v0.1.2

func IsRequired(tags *structtag.Tags) bool

IsRequired checks if a field is required based on its tags

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() []any
}

AllOfExposer exposes "allOf" items as list of samples.

type AnyOfExposer added in v0.0.4

type AnyOfExposer interface {
	JSONSchemaAnyOf() []any
}

AnyOfExposer exposes "anyOf" items as list of samples.

type Contact

type Contact = openapi3.Contact

type ElseExposer added in v0.0.4

type ElseExposer interface {
	JSONSchemaElse() any
}

ElseExposer exposes "else" schema as a sample.

type Enum added in v0.0.4

type Enum interface {
	Enum() []any
}

Enum returns the enumerated acceptable values.

type IfExposer added in v0.0.4

type IfExposer interface {
	JSONSchemaIf() any
}

IfExposer exposes "if" schema as a sample.

type License

type License = openapi3.License

type NamedEnum added in v0.0.4

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

NamedEnum returns the enumerated acceptable values with according string names.

type NotExposer added in v0.0.4

type NotExposer interface {
	JSONSchemaNot() any
}

NotExposer exposes "not" schema as a sample.

type OneOfExposer added in v0.0.4

type OneOfExposer interface {
	JSONSchemaOneOf() []any
}

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 any) *Operation

func (*Operation) AddSecurity

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

func (*Operation) AddTags added in v0.1.1

func (op *Operation) AddTags(tags ...string) *Operation

func (*Operation) GetDescription added in v0.1.2

func (op *Operation) GetDescription() string

GetDescription returns the operation's description

func (*Operation) GetMethod added in v0.1.2

func (op *Operation) GetMethod() string

GetMethod returns the operation's HTTP method

func (*Operation) GetOperationID added in v0.1.2

func (op *Operation) GetOperationID() string

GetOperationID returns the operation's ID

func (*Operation) GetPath added in v0.1.2

func (op *Operation) GetPath() string

GetPath returns the operation's path

func (*Operation) GetSummary added in v0.1.2

func (op *Operation) GetSummary() string

GetSummary returns the operation's summary

func (*Operation) GetTags added in v0.1.2

func (op *Operation) GetTags() []string

GetTags returns the operation's tags

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 any) *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) AddTags added in v0.1.1

func (s *Service) AddTags(tags ...string) *Service

func (*Service) DeleteOf

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

func (*Service) GetName added in v0.1.2

func (s *Service) GetName() string

GetName returns the service's name

func (*Service) GetOf

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

func (*Service) GetOperations added in v0.1.2

func (s *Service) GetOperations() []*Operation

GetOperations returns all operations in the service

func (*Service) GetPath added in v0.1.2

func (s *Service) GetPath() string

GetPath returns the service's prefix path

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 {
	Title          string
	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) BuildSwagger added in v0.1.2

func (s *Swagger) BuildSwagger() *openapi3.T

func (*Swagger) MarshalJSON

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

func (*Swagger) MarshalYAML

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

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() any
}

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