Documentation
¶
Index ¶
- type Generator
- func (g *Generator) Add(method, path string, opts ...option.OperationOption) Route
- func (g *Generator) Config() *openapi.Config
- func (g *Generator) Delete(path string, opts ...option.OperationOption) Route
- func (g *Generator) GenerateSchema(formats ...string) ([]byte, error)
- func (g *Generator) Get(path string, opts ...option.OperationOption) Route
- func (g *Generator) Group(pattern string, opts ...option.GroupOption) Router
- func (g *Generator) Head(path string, opts ...option.OperationOption) Route
- func (g *Generator) Options(path string, opts ...option.OperationOption) Route
- func (g *Generator) Patch(path string, opts ...option.OperationOption) Route
- func (g *Generator) Post(path string, opts ...option.OperationOption) Route
- func (g *Generator) Put(path string, opts ...option.OperationOption) Route
- func (g *Generator) Route(pattern string, fn func(router Router), opts ...option.GroupOption) Router
- func (g *Generator) Trace(path string, opts ...option.OperationOption) Route
- func (g *Generator) Use(opts ...option.GroupOption) Router
- func (g *Generator) Validate() error
- func (g *Generator) WriteSchemaTo(path string) error
- type Route
- type Router
- type SpecError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is a struct that implements the Router interface. It is used to generate OpenAPI specifications based on the defined routes and operations.
func NewGenerator ¶
func NewGenerator(opts ...option.OpenAPIOption) *Generator
NewGenerator creates a new Generator instance with the provided OpenAPI options.
It initializes the reflector and sets up the OpenAPI configuration.
func NewRouter ¶ added in v0.1.3
func NewRouter(opts ...option.OpenAPIOption) *Generator
NewRouter creates a new Router instance with the provided OpenAPI options.
It initializes the reflector and sets up the OpenAPI configuration.
func (*Generator) Add ¶ added in v0.1.2
func (g *Generator) Add(method, path string, opts ...option.OperationOption) Route
Add registers a new operation with the specified method and path. It applies the provided operation options to the operation context.
func (*Generator) Config ¶ added in v0.1.2
Config returns the OpenAPI configuration used by the Router.
func (*Generator) Delete ¶ added in v0.1.2
func (g *Generator) Delete(path string, opts ...option.OperationOption) Route
Delete registers a new DELETE operation with the specified path and options.
func (*Generator) GenerateSchema ¶
GenerateSchema generates the OpenAPI schema in the specified format (JSON or YAML).
By default, it generates YAML. If "json" is specified, it generates JSON.
func (*Generator) Get ¶ added in v0.1.2
func (g *Generator) Get(path string, opts ...option.OperationOption) Route
Get registers a new GET operation with the specified path and options.
func (*Generator) Group ¶ added in v0.1.3
func (g *Generator) Group(pattern string, opts ...option.GroupOption) Router
Group creates a new sub-router with the specified prefix and options.
func (*Generator) Head ¶ added in v0.1.2
func (g *Generator) Head(path string, opts ...option.OperationOption) Route
Head registers a new HEAD operation with the specified path and options.
func (*Generator) Options ¶ added in v0.1.2
func (g *Generator) Options(path string, opts ...option.OperationOption) Route
Options registers a new OPTIONS operation with the specified path and options.
func (*Generator) Patch ¶ added in v0.1.2
func (g *Generator) Patch(path string, opts ...option.OperationOption) Route
Patch registers a new PATCH operation with the specified path and options.
func (*Generator) Post ¶ added in v0.1.2
func (g *Generator) Post(path string, opts ...option.OperationOption) Route
Post registers a new POST operation with the specified path and options.
func (*Generator) Put ¶ added in v0.1.2
func (g *Generator) Put(path string, opts ...option.OperationOption) Route
Put registers a new PUT operation with the specified path and options.
func (*Generator) Route ¶ added in v0.1.3
func (g *Generator) Route(pattern string, fn func(router Router), opts ...option.GroupOption) Router
Route registers a new route with the specified pattern and function.
The function receives a Router instance to define sub-routes.
func (*Generator) Trace ¶ added in v0.1.2
func (g *Generator) Trace(path string, opts ...option.OperationOption) Route
Trace registers a new TRACE operation with the specified path and options.
func (*Generator) Use ¶ added in v0.1.3
func (g *Generator) Use(opts ...option.GroupOption) Router
Use applies the provided options to the router.
func (*Generator) Validate ¶ added in v0.1.2
Validate checks if the generated OpenAPI specification is valid.
func (*Generator) WriteSchemaTo ¶
WriteSchemaTo writes the OpenAPI schema to the specified file path.
The file format is determined by the file extension: ".json" for JSON and ".yaml" for YAML.
type Route ¶ added in v0.1.3
type Route interface {
// With applies the provided operation options to the route.
With(opts ...option.OperationOption) Route
}
Route defines a method for creating a new route with the specified options.
type Router ¶ added in v0.1.3
type Router interface {
// Get registers a new GET operation with the specified path and options.
Get(path string, opts ...option.OperationOption) Route
// Post registers a new POST operation with the specified path and options.
Post(path string, opts ...option.OperationOption) Route
// Put registers a new PUT operation with the specified path and options.
Put(path string, opts ...option.OperationOption) Route
// Delete registers a new DELETE operation with the specified path and options.
Delete(path string, opts ...option.OperationOption) Route
// Patch registers a new PATCH operation with the specified path and options.
Patch(path string, opts ...option.OperationOption) Route
// Options registers a new OPTIONS operation with the specified path and options.
Options(path string, opts ...option.OperationOption) Route
// Head registers a new HEAD operation with the specified path and options.
Head(path string, opts ...option.OperationOption) Route
// Add registers a new operation with the specified method and path.
Add(method, path string, opts ...option.OperationOption) Route
// Trace registers a new TRACE operation with the specified path and options.
Trace(path string, opts ...option.OperationOption) Route
// Route registers a new route with the specified pattern and function.
// The function receives a Router instance to define sub-routes.
Route(pattern string, fn func(router Router), opts ...option.GroupOption) Router
// Group creates a new sub-router with the specified prefix and options.
Group(pattern string, opts ...option.GroupOption) Router
// Use applies the provided options to the router.
Use(opts ...option.GroupOption) Router
}
Router is an interface that defines methods for registering routes and operations in an OpenAPI specification. It allows for defining HTTP methods, paths, and operation options.
type SpecError ¶ added in v0.1.2
type SpecError struct {
// contains filtered or unexported fields
}
SpecError is a thread-safe error collector for OpenAPI specifications.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapter
|
|
|
chiopenapi
module
|
|
|
echoopenapi
module
|
|
|
fiberopenapi
module
|
|
|
ginopenapi
module
|
|
|
httpopenapi
module
|
|
|
httprouteropenapi
module
|
|
|
muxopenapi
module
|
|
|
adapters
|
|
|
chiopenapi
module
|
|
|
echoopenapi
module
|
|
|
fiberopenapi
module
|
|
|
ginopenapi
module
|
|
|
httpopenapi
module
|
|
|
internal
|
|
|
module
|
|
|
specui
module
|
|
|
pkg
|
|