operation

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouterComment

func NewRouterComment() *routerComment

func Register

func Register(c Comment)

Register registers a comment to the default registry.

Types

type Comment

type Comment interface {
	Tag() string
	Usage() string
	ParseInto(c string, f *ast.File, op *Operation) error
}

Comment defines the interface for operation-level OpenAPI annotations.

type DeprecatedComment

type DeprecatedComment struct{}

DeprecatedComment marks an operation as deprecated.

func NewDeprecatedComment

func NewDeprecatedComment() *DeprecatedComment

func (*DeprecatedComment) ParseInto

func (c *DeprecatedComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*DeprecatedComment) Tag

func (c *DeprecatedComment) Tag() string

func (*DeprecatedComment) Usage

func (c *DeprecatedComment) Usage() string

type DescriptionComment

type DescriptionComment struct{}

DescriptionComment sets the description of an operation.

func NewDescriptionComment

func NewDescriptionComment() *DescriptionComment

func (*DescriptionComment) ParseInto

func (c *DescriptionComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*DescriptionComment) Tag

func (c *DescriptionComment) Tag() string

func (*DescriptionComment) Usage

func (c *DescriptionComment) Usage() string

type ExternalDocsDescriptionComment

type ExternalDocsDescriptionComment struct{}

ExternalDocsDescriptionComment sets the description for an operation's external documentation.

func NewExternalDocsDescriptionComment

func NewExternalDocsDescriptionComment() *ExternalDocsDescriptionComment

func (*ExternalDocsDescriptionComment) ParseInto

func (c *ExternalDocsDescriptionComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ExternalDocsDescriptionComment) Tag

func (*ExternalDocsDescriptionComment) Usage

type ExternalDocsURLComment

type ExternalDocsURLComment struct{}

ExternalDocsURLComment sets the URL for an operation's external documentation.

func NewExternalDocsURLComment

func NewExternalDocsURLComment() *ExternalDocsURLComment

func (*ExternalDocsURLComment) ParseInto

func (c *ExternalDocsURLComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ExternalDocsURLComment) Tag

func (c *ExternalDocsURLComment) Tag() string

func (*ExternalDocsURLComment) Usage

func (c *ExternalDocsURLComment) Usage() string

type IDComment

type IDComment struct{}

IDComment sets the operationId of an operation.

func NewIDComment

func NewIDComment() *IDComment

func (*IDComment) ParseInto

func (c *IDComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*IDComment) Tag

func (c *IDComment) Tag() string

func (*IDComment) Usage

func (c *IDComment) Usage() string

type MockComment

type MockComment struct {
	mock.Mock
}

MockComment is an autogenerated mock type for the Comment type

func NewMockComment

func NewMockComment(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockComment

NewMockComment creates a new instance of MockComment. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockComment) EXPECT

func (_m *MockComment) EXPECT() *MockComment_Expecter

func (*MockComment) ParseInto

func (_mock *MockComment) ParseInto(c string, f *ast.File, op *Operation) error

ParseInto provides a mock function for the type MockComment

func (*MockComment) Tag

func (_mock *MockComment) Tag() string

Tag provides a mock function for the type MockComment

func (*MockComment) Usage

func (_mock *MockComment) Usage() string

Usage provides a mock function for the type MockComment

type MockComment_Expecter

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

func (*MockComment_Expecter) ParseInto

func (_e *MockComment_Expecter) ParseInto(c interface{}, f interface{}, op interface{}) *MockComment_ParseInto_Call

ParseInto is a helper method to define mock.On call

  • c string
  • f *ast.File
  • op *Operation

func (*MockComment_Expecter) Tag

Tag is a helper method to define mock.On call

func (*MockComment_Expecter) Usage

Usage is a helper method to define mock.On call

type MockComment_ParseInto_Call

type MockComment_ParseInto_Call struct {
	*mock.Call
}

MockComment_ParseInto_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ParseInto'

func (*MockComment_ParseInto_Call) Return

func (*MockComment_ParseInto_Call) Run

func (*MockComment_ParseInto_Call) RunAndReturn

func (_c *MockComment_ParseInto_Call) RunAndReturn(run func(c string, f *ast.File, op *Operation) error) *MockComment_ParseInto_Call

type MockComment_Tag_Call

type MockComment_Tag_Call struct {
	*mock.Call
}

MockComment_Tag_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Tag'

func (*MockComment_Tag_Call) Return

func (*MockComment_Tag_Call) Run

func (_c *MockComment_Tag_Call) Run(run func()) *MockComment_Tag_Call

func (*MockComment_Tag_Call) RunAndReturn

func (_c *MockComment_Tag_Call) RunAndReturn(run func() string) *MockComment_Tag_Call

type MockComment_Usage_Call

type MockComment_Usage_Call struct {
	*mock.Call
}

MockComment_Usage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Usage'

func (*MockComment_Usage_Call) Return

func (*MockComment_Usage_Call) Run

func (_c *MockComment_Usage_Call) Run(run func()) *MockComment_Usage_Call

func (*MockComment_Usage_Call) RunAndReturn

func (_c *MockComment_Usage_Call) RunAndReturn(run func() string) *MockComment_Usage_Call

type MockRegistry

type MockRegistry struct {
	mock.Mock
}

MockRegistry is an autogenerated mock type for the Registry type

func NewMockRegistry

func NewMockRegistry(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRegistry

NewMockRegistry creates a new instance of MockRegistry. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRegistry) Comments

func (_mock *MockRegistry) Comments() []Comment

Comments provides a mock function for the type MockRegistry

func (*MockRegistry) EXPECT

func (_m *MockRegistry) EXPECT() *MockRegistry_Expecter

func (*MockRegistry) Parse

func (_mock *MockRegistry) Parse(line string, f *ast.File, op *Operation) error

Parse provides a mock function for the type MockRegistry

func (*MockRegistry) Register

func (_mock *MockRegistry) Register(c Comment)

Register provides a mock function for the type MockRegistry

type MockRegistry_Comments_Call

type MockRegistry_Comments_Call struct {
	*mock.Call
}

MockRegistry_Comments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Comments'

func (*MockRegistry_Comments_Call) Return

func (*MockRegistry_Comments_Call) Run

func (*MockRegistry_Comments_Call) RunAndReturn

func (_c *MockRegistry_Comments_Call) RunAndReturn(run func() []Comment) *MockRegistry_Comments_Call

type MockRegistry_Expecter

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

func (*MockRegistry_Expecter) Comments

Comments is a helper method to define mock.On call

func (*MockRegistry_Expecter) Parse

func (_e *MockRegistry_Expecter) Parse(line interface{}, f interface{}, op interface{}) *MockRegistry_Parse_Call

Parse is a helper method to define mock.On call

  • line string
  • f *ast.File
  • op *Operation

func (*MockRegistry_Expecter) Register

func (_e *MockRegistry_Expecter) Register(c interface{}) *MockRegistry_Register_Call

Register is a helper method to define mock.On call

  • c Comment

type MockRegistry_Parse_Call

type MockRegistry_Parse_Call struct {
	*mock.Call
}

MockRegistry_Parse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Parse'

func (*MockRegistry_Parse_Call) Return

func (*MockRegistry_Parse_Call) Run

func (_c *MockRegistry_Parse_Call) Run(run func(line string, f *ast.File, op *Operation)) *MockRegistry_Parse_Call

func (*MockRegistry_Parse_Call) RunAndReturn

func (_c *MockRegistry_Parse_Call) RunAndReturn(run func(line string, f *ast.File, op *Operation) error) *MockRegistry_Parse_Call

type MockRegistry_Register_Call

type MockRegistry_Register_Call struct {
	*mock.Call
}

MockRegistry_Register_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Register'

func (*MockRegistry_Register_Call) Return

func (*MockRegistry_Register_Call) Run

func (*MockRegistry_Register_Call) RunAndReturn

func (_c *MockRegistry_Register_Call) RunAndReturn(run func(c Comment)) *MockRegistry_Register_Call

type Operation

type Operation struct {
	Builder          *openapi.OperationBuilder
	ResponsesBuilder *openapi.ResponsesBuilder
	Routes           Routes
	Resolver         resolver.Resolver
}

Operation holds an operation being built

func NewOperation

func NewOperation(resolver resolver.Resolver) *Operation

NewOperation builds a new operation

func (*Operation) Attach

func (o *Operation) Attach(spec *openapi.Extendable[openapi.OpenAPI]) error

Attach attaches the operation to the given openapi spec.

type ParamAllowEmptyValueComment

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

ParamAllowEmptyValueComment sets the allowEmptyValue flag for a parameter in an operation.

func NewParamAllowEmptyValueComment

func NewParamAllowEmptyValueComment() *ParamAllowEmptyValueComment

func (*ParamAllowEmptyValueComment) ParseInto

func (c *ParamAllowEmptyValueComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ParamAllowEmptyValueComment) Tag

func (c *ParamAllowEmptyValueComment) Tag() string

func (*ParamAllowEmptyValueComment) Usage

func (c *ParamAllowEmptyValueComment) Usage() string

type ParamAllowReservedComment

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

ParamAllowReservedComment sets the allowReserved flag for a parameter in an operation.

func NewParamAllowReservedComment

func NewParamAllowReservedComment() *ParamAllowReservedComment

func (*ParamAllowReservedComment) ParseInto

func (c *ParamAllowReservedComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ParamAllowReservedComment) Tag

func (c *ParamAllowReservedComment) Tag() string

func (*ParamAllowReservedComment) Usage

func (c *ParamAllowReservedComment) Usage() string

type ParamComment

type ParamComment struct{}

ParamComment adds a parameter to an operation.

func NewParamComment

func NewParamComment() *ParamComment

func (*ParamComment) ParseInto

func (c *ParamComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ParamComment) Tag

func (c *ParamComment) Tag() string

func (*ParamComment) Usage

func (c *ParamComment) Usage() string

type ParamDeprecatedComment

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

ParamDeprecatedComment sets the deprecated flag for a parameter in an operation.

func NewParamDeprecatedComment

func NewParamDeprecatedComment() *ParamDeprecatedComment

func (*ParamDeprecatedComment) ParseInto

func (c *ParamDeprecatedComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ParamDeprecatedComment) Tag

func (c *ParamDeprecatedComment) Tag() string

func (*ParamDeprecatedComment) Usage

func (c *ParamDeprecatedComment) Usage() string

type ParamRequiredComment

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

ParamRequiredComment sets the required flag for a parameter in an operation.

func NewParamRequiredComment

func NewParamRequiredComment() *ParamRequiredComment

func (*ParamRequiredComment) ParseInto

func (c *ParamRequiredComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ParamRequiredComment) Tag

func (c *ParamRequiredComment) Tag() string

func (*ParamRequiredComment) Usage

func (c *ParamRequiredComment) Usage() string

type Registry

type Registry interface {
	Register(c Comment)
	Parse(line string, f *ast.File, op *Operation) error
	Comments() []Comment
}

Registry allows to register and parse comments.

func Default

func Default() Registry

func NewRegistry

func NewRegistry() Registry

NewRegistry creates a new Registry.

type RequestBodyComment

type RequestBodyComment struct{}

RequestBodyComment defines the request body for an operation.

func NewRequestBodyComment

func NewRequestBodyComment() *RequestBodyComment

func (*RequestBodyComment) ParseInto

func (c *RequestBodyComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*RequestBodyComment) Tag

func (c *RequestBodyComment) Tag() string

func (*RequestBodyComment) Usage

func (c *RequestBodyComment) Usage() string

type ResponseComment

type ResponseComment struct{}

ResponseComment adds a response to an operation.

func NewResponseComment

func NewResponseComment() *ResponseComment

func (*ResponseComment) ParseInto

func (c *ResponseComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*ResponseComment) Tag

func (c *ResponseComment) Tag() string

func (*ResponseComment) Usage

func (c *ResponseComment) Usage() string

type Route

type Route struct {
	Path   string
	Method string
}

Route defines a path and a method

type Routes

type Routes []Route

Routes is a type alias for a slice of Route

func (Routes) Summarize

func (r Routes) Summarize() map[string][]string

Summarize returns a map of paths to methods for the operation.

type SecurityComment

type SecurityComment struct{}

SecurityComment is a comment that updates the security of an operation.

func NewSecurityComment

func NewSecurityComment() *SecurityComment

func (*SecurityComment) ParseInto

func (d *SecurityComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*SecurityComment) Tag

func (d *SecurityComment) Tag() string

func (*SecurityComment) Usage

func (d *SecurityComment) Usage() string

type SecurityNoneComment

type SecurityNoneComment struct{}

SecurityNoneComment is a comment that clears the security of an operation.

func NewSecurityNoneComment

func NewSecurityNoneComment() *SecurityNoneComment

func (*SecurityNoneComment) ParseInto

func (d *SecurityNoneComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*SecurityNoneComment) Tag

func (d *SecurityNoneComment) Tag() string

func (*SecurityNoneComment) Usage

func (d *SecurityNoneComment) Usage() string

type ServerDescriptionComment

type ServerDescriptionComment struct{}

ServerDescriptionComment sets the description for the last added server of an operation.

func (*ServerDescriptionComment) ParseInto

func (c *ServerDescriptionComment) ParseInto(content string, f *ast.File, op *Operation) error

ParseInto implements Comment.

func (*ServerDescriptionComment) Tag

Tag implements Comment.

func (*ServerDescriptionComment) Usage

func (c *ServerDescriptionComment) Usage() string

Usage implements Comment.

type ServerURLComment

type ServerURLComment struct{}

ServerURLComment is a comment that adds a new server to the operation.

func (*ServerURLComment) ParseInto

func (c *ServerURLComment) ParseInto(content string, f *ast.File, op *Operation) error

ParseInto implements Comment.

func (*ServerURLComment) Tag

func (c *ServerURLComment) Tag() string

Tag implements Comment.

func (*ServerURLComment) Usage

func (c *ServerURLComment) Usage() string

Usage implements Comment.

type ServerVariableDefaultComment

type ServerVariableDefaultComment struct{}

ServerVariableDefaultComment sets the default value for a server variable on an operation.

func (*ServerVariableDefaultComment) ParseInto

func (c *ServerVariableDefaultComment) ParseInto(content string, f *ast.File, op *Operation) error

ParseInto implements Comment.

func (*ServerVariableDefaultComment) Tag

Tag implements Comment.

func (*ServerVariableDefaultComment) Usage

Usage implements Comment.

type ServerVariableDescriptionComment

type ServerVariableDescriptionComment struct{}

ServerVariableDescriptionComment sets the description for a server variable on an operation.

func (*ServerVariableDescriptionComment) ParseInto

func (c *ServerVariableDescriptionComment) ParseInto(content string, f *ast.File, op *Operation) error

ParseInto implements Comment.

func (*ServerVariableDescriptionComment) Tag

Tag implements Comment.

func (*ServerVariableDescriptionComment) Usage

Usage implements Comment.

type ServerVariableEnumComment

type ServerVariableEnumComment struct{}

ServerVariableEnumComment sets the enum values for a server variable on an operation.

func (*ServerVariableEnumComment) ParseInto

func (c *ServerVariableEnumComment) ParseInto(content string, f *ast.File, op *Operation) error

ParseInto implements Comment.

func (*ServerVariableEnumComment) Tag

Tag implements Comment.

func (*ServerVariableEnumComment) Usage

func (c *ServerVariableEnumComment) Usage() string

Usage implements Comment.

type SummaryComment

type SummaryComment struct{}

SummaryComment sets the summary of an operation.

func NewSummaryComment

func NewSummaryComment() *SummaryComment

func (*SummaryComment) ParseInto

func (c *SummaryComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*SummaryComment) Tag

func (c *SummaryComment) Tag() string

func (*SummaryComment) Usage

func (c *SummaryComment) Usage() string

type TagsComment

type TagsComment struct{}

TagsComment adds tags to an operation.

func NewTagsComment

func NewTagsComment() *TagsComment

func (*TagsComment) ParseInto

func (c *TagsComment) ParseInto(content string, f *ast.File, op *Operation) error

func (*TagsComment) Tag

func (c *TagsComment) Tag() string

func (*TagsComment) Usage

func (c *TagsComment) Usage() string

Jump to

Keyboard shortcuts

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