Documentation
¶
Index ¶
- Variables
- func GoDocForStruct(t reflect.Type) (string, map[string]string, error)
- func MappedName(typName string, pkgMap []PackageMap) string
- type Document
- func (d *Document) AddSecurityRequirement(reqs map[string][]string) *Document
- func (d *Document) AddServer(url string) *Document
- func (d *Document) Delete(pattern string) *Operation
- func (d *Document) Description(description string) *Document
- func (d *Document) Get(pattern string) *Operation
- func (d *Document) Operations(ctx context.Context) []*Operation
- func (d *Document) PackageMap(pairs ...string) *Document
- func (d *Document) Post(pattern string) *Operation
- func (d *Document) Put(pattern string) *Operation
- func (d *Document) Refresh() error
- func (d *Document) SchemaComponent(fqn string, m *Model) *Document
- func (d *Document) SchemaComponentRef(m *Model) *SchemaComponent
- func (d *Document) SchemaComponents(ctx context.Context) []*SchemaComponent
- func (d *Document) SecuritySchemeComponent(fqn string, m *SecurityScheme) *Document
- func (d *Document) Title(title string) *Document
- func (d *Document) Version(version string) *Document
- type ErrHandler
- type ErrHelper
- type Header
- type JSONTag
- type Model
- type OpenAPITag
- type Operation
- func (o *Operation) Description(description string) *Operation
- func (o *Operation) OperationID(id string) *Operation
- func (o *Operation) Parameters(ps *Parameters) *Operation
- func (o *Operation) RequestBody(mt string, model *Model) *Operation
- func (o *Operation) Response(code string, cb func(r *Response)) *Operation
- func (o *Operation) SecurityRequirement(reqs map[string][]string) *Operation
- func (o *Operation) Summary(summary string) *Operation
- func (o *Operation) Tags(tags ...string) *Operation
- type PackageMap
- type Parameter
- type Parameters
- type Response
- type SchemaComponent
- type SecurityScheme
- func SecuritySchemeAPIAuthKey(in string, name string) *SecurityScheme
- func SecuritySchemeBasicAuth() *SecurityScheme
- func SecuritySchemeBearerAuth() *SecurityScheme
- func SecuritySchemeBearerAuthWithFormat(format string) *SecurityScheme
- func SecuritySchemeCookieAuth(name string) *SecurityScheme
- func SecuritySchemeForType(typ string) *SecurityScheme
- func SecuritySchemeOAuth2AuthorizationCode(authorizationURL string, tokenURL string, scopes map[string]string) *SecurityScheme
- func SecuritySchemeOAuth2ClientCredentials(tokenURL string, scopes map[string]string) *SecurityScheme
- func SecuritySchemeOAuth2Implicit(authorizationURL string, scopes map[string]string) *SecurityScheme
- func SecuritySchemeOAuth2Password(tokenURL string, scopes map[string]string) *SecurityScheme
- func (s *SecurityScheme) AllDefinedFlows() *regardingFlow
- func (s *SecurityScheme) AllFlows() *regardingFlow
- func (s *SecurityScheme) AuthorizationCodeFlow() *regardingFlow
- func (s *SecurityScheme) BearerFormat(format string) *SecurityScheme
- func (s *SecurityScheme) ClientCredentialsFlow() *regardingFlow
- func (s *SecurityScheme) Description(description string) *SecurityScheme
- func (s *SecurityScheme) ImplicitFlow() *regardingFlow
- func (s *SecurityScheme) In(in string) *SecurityScheme
- func (s *SecurityScheme) Name(name string) *SecurityScheme
- func (s *SecurityScheme) PasswordFlow() *regardingFlow
- func (s *SecurityScheme) Scheme(scheme string) *SecurityScheme
- type TagInfo
- func (info *TagInfo) ElemRefName() string
- func (info *TagInfo) HasIn() bool
- func (info *TagInfo) HasName() bool
- func (into *TagInfo) In() string
- func (info *TagInfo) IsIgnored() bool
- func (info *TagInfo) Name() string
- func (info *TagInfo) Props() map[string]string
- func (info *TagInfo) RefName() string
- func (info *TagInfo) ReplacementType() string
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedModelType = errors.New("unsupported model type")
ErrUnsupportedModelType is returned when the model type is not supported.
var ErrUnsupportedParameterType = errors.New("unsupported parameter type")
ErrUnsupportedParameterType is returned when a parameter is created from an unsupported type.
Functions ¶
func MappedName ¶
func MappedName(typName string, pkgMap []PackageMap) string
Types ¶
type Document ¶
type Document struct { // OpenAPI is the underlying OpenAPI document. OpenAPI libopenapi.Document // DataModel is the v3 DataModel from the document. DataModel *libopenapi.DocumentModel[v3.Document] // PackageMap maps OpenAPI "package names" to Go package names. This is // used in SchemaComponentRef. PkgMap []PackageMap ErrHelper }
Document providees DSL methods for creating OpenAPI documents.
func NewDocument ¶
NewDocument creates a new Document with the given title.
func NewDocumentFrom ¶
func NewDocumentFrom(doc libopenapi.Document) (*Document, error)
NewDocumentFrom creates a new Document from a v3.Document. This allows you to add to an existing document using the DSL.
func NewDocumentFromBytes ¶
NewDocumentFromBytes creates a new Document from raw YAML bytes.
func (*Document) AddSecurityRequirement ¶
AddSecurityRequirement configures the global security scopes. The key in the map is the security scheme name and the value is the list of scopes.
func (*Document) Delete ¶
Delete creates a new DELETE operation at the given pattern. The Operation is returned to be manipulated further.
func (*Document) Description ¶
func (*Document) Get ¶
Get creates a new GET operation at the given pattern. The Operation is returned to be manipulated further.
func (*Document) Operations ¶
Operations lists all the operations in the document.
func (*Document) PackageMap ¶
func (*Document) Post ¶
Post creates a new POST operation at the given pattern. The Operation is returned to be manipulated further.
func (*Document) Put ¶
Put creates a new PUT operation at the given pattern. The Operation is returned to be manipulated further.
func (*Document) SchemaComponent ¶
SchemaComponent adds a schema component to the document. You can then use
arrest.SchemaRef(fqn)
to reference this schema in other parts of the document.
func (*Document) SchemaComponentRef ¶
func (d *Document) SchemaComponentRef(m *Model) *SchemaComponent
func (*Document) SchemaComponents ¶
func (d *Document) SchemaComponents(ctx context.Context) []*SchemaComponent
SchemaComponents lists all the schema components in the document.
func (*Document) SecuritySchemeComponent ¶
func (d *Document) SecuritySchemeComponent(fqn string, m *SecurityScheme) *Document
SecuritySchemeComponent adds a security scheme component to the document. You can then use the fqn to reference this schema in other parts of the document.
type ErrHandler ¶
type ErrHandler interface { Err() error Errs() []error AddError(...error) AddHandler(...ErrHandler) }
ErrHandler is the interface that all DSL object implement to allow errors to flow upward to parent components.
type ErrHelper ¶
type ErrHelper struct {
// contains filtered or unexported fields
}
ErrHelper implements the ErrHandler to make implementation of the interface as easy as embedding ErrHelper into the struct.
func (*ErrHelper) AddHandler ¶
func (e *ErrHelper) AddHandler(handlers ...ErrHandler)
AddHandler is used internally to add child component errors to the parent.
type Header ¶
Header provides DSL methods for creating OpenAPI headers.
func (*Header) Description ¶
Description sets the description of the header.
type Model ¶
type Model struct { Name string SchemaProxy *base.SchemaProxy ErrHelper // contains filtered or unexported fields }
Model provides DSL methods for creating OpenAPI schema objects based on Go types.
func ModelFromReflect ¶
ModelFromReflect creates a new Model from a reflect.Type.
func (*Model) Description ¶
func (*Model) ExtractChildRefs ¶
func (m *Model) ExtractChildRefs() map[string]*base.SchemaProxy
func (*Model) MappedName ¶
func (m *Model) MappedName(pkgMap []PackageMap) string
type OpenAPITag ¶
type OpenAPITag string
func (OpenAPITag) HasName ¶
func (tag OpenAPITag) HasName() bool
func (OpenAPITag) IsIgnored ¶
func (tag OpenAPITag) IsIgnored() bool
func (OpenAPITag) Name ¶
func (tag OpenAPITag) Name() string
func (OpenAPITag) Parts ¶
func (tag OpenAPITag) Parts() []string
func (OpenAPITag) Props ¶
func (tag OpenAPITag) Props() map[string]string
type Operation ¶
Operation provides DSL methods for creating OpenAPI operations.
func (*Operation) Description ¶
Description sets the description for the operation.
func (*Operation) OperationID ¶
OperationID sets the operation ID for the operation.
func (*Operation) Parameters ¶
func (o *Operation) Parameters(ps *Parameters) *Operation
Parameters adds parameters to the operation.
func (*Operation) RequestBody ¶
RequestBody sets the request body for the operation.
func (*Operation) SecurityRequirement ¶
SecurityRequirement configures the security scopes for this operation. The key in the map is the security scheme name and the value is the list of scopes.
type PackageMap ¶
type Parameter ¶
Parameter provides DSL methods for creating individual OpenAPI parameters.
func ParameterFrom ¶
ParameterFrom creates a new Parameter from a type.
func ParameterFromReflect ¶
ParameterFromReflect creates a new Parameter from a reflect.Type.
func (*Parameter) Description ¶
Description sets the description of the parameter.
type Parameters ¶
Parameters provides DSL methods for creating multiple OpenAPI parameters.
func NParameters ¶
func NParameters(n int) *Parameters
NParameters creates a new Parameters with the given number of parameters.
func ParametersFrom ¶
func ParametersFrom[T any]() *Parameters
ParametersFrom creates a new Parameters from a type.
func ParametersFromReflect ¶
func ParametersFromReflect(t reflect.Type) *Parameters
ParametersFromReflect creates a new Parameters from a reflect.Type. Given the reflect.Type for a function, it will use the function parameters to create the base list of parameters. You will need to use the P() method to access the parameters and set names in that case.
func (*Parameters) P ¶
func (p *Parameters) P(idx int, cb func(p *Parameter)) *Parameters
P returns the parameter at the given index and calls the callback with it.
type Response ¶
Response provides DSL methods for creating OpenAPI responses.
func (*Response) Description ¶
Description sets the description of the response.
type SchemaComponent ¶
type SchemaComponent struct {
// contains filtered or unexported fields
}
func NewSchemaComponent ¶
func NewSchemaComponent(schema *Model, ref *Model) *SchemaComponent
func (*SchemaComponent) Description ¶
func (s *SchemaComponent) Description(description string) *SchemaComponent
func (*SchemaComponent) Ref ¶
func (s *SchemaComponent) Ref() *Model
func (*SchemaComponent) Schema ¶
func (s *SchemaComponent) Schema() *Model
type SecurityScheme ¶
type SecurityScheme struct {
SecurityScheme *highv3.SecurityScheme
}
func SecuritySchemeAPIAuthKey ¶
func SecuritySchemeAPIAuthKey(in string, name string) *SecurityScheme
func SecuritySchemeBasicAuth ¶
func SecuritySchemeBasicAuth() *SecurityScheme
func SecuritySchemeBearerAuth ¶
func SecuritySchemeBearerAuth() *SecurityScheme
func SecuritySchemeBearerAuthWithFormat ¶
func SecuritySchemeBearerAuthWithFormat(format string) *SecurityScheme
func SecuritySchemeCookieAuth ¶
func SecuritySchemeCookieAuth(name string) *SecurityScheme
func SecuritySchemeForType ¶
func SecuritySchemeForType(typ string) *SecurityScheme
func SecuritySchemeOAuth2AuthorizationCode ¶
func SecuritySchemeOAuth2AuthorizationCode( authorizationURL string, tokenURL string, scopes map[string]string, ) *SecurityScheme
func SecuritySchemeOAuth2ClientCredentials ¶
func SecuritySchemeOAuth2ClientCredentials( tokenURL string, scopes map[string]string, ) *SecurityScheme
func SecuritySchemeOAuth2Implicit ¶
func SecuritySchemeOAuth2Implicit( authorizationURL string, scopes map[string]string, ) *SecurityScheme
func SecuritySchemeOAuth2Password ¶
func SecuritySchemeOAuth2Password( tokenURL string, scopes map[string]string, ) *SecurityScheme
func (*SecurityScheme) AllDefinedFlows ¶
func (s *SecurityScheme) AllDefinedFlows() *regardingFlow
func (*SecurityScheme) AllFlows ¶
func (s *SecurityScheme) AllFlows() *regardingFlow
func (*SecurityScheme) AuthorizationCodeFlow ¶
func (s *SecurityScheme) AuthorizationCodeFlow() *regardingFlow
func (*SecurityScheme) BearerFormat ¶
func (s *SecurityScheme) BearerFormat(format string) *SecurityScheme
func (*SecurityScheme) ClientCredentialsFlow ¶
func (s *SecurityScheme) ClientCredentialsFlow() *regardingFlow
func (*SecurityScheme) Description ¶
func (s *SecurityScheme) Description(description string) *SecurityScheme
func (*SecurityScheme) ImplicitFlow ¶
func (s *SecurityScheme) ImplicitFlow() *regardingFlow
func (*SecurityScheme) In ¶
func (s *SecurityScheme) In(in string) *SecurityScheme
func (*SecurityScheme) Name ¶
func (s *SecurityScheme) Name(name string) *SecurityScheme
func (*SecurityScheme) PasswordFlow ¶
func (s *SecurityScheme) PasswordFlow() *regardingFlow
func (*SecurityScheme) Scheme ¶
func (s *SecurityScheme) Scheme(scheme string) *SecurityScheme
type TagInfo ¶
type TagInfo struct {
// contains filtered or unexported fields
}