Documentation
¶
Overview ¶
Package godoclive provides a public API for analyzing Go HTTP services and generating interactive API documentation.
Index ¶
- func Generate(endpoints []EndpointDef, opts ...Option) error
- func GenerateOpenAPI(endpoints []EndpointDef, opts ...Option) ([]byte, error)
- type EndpointDef
- type Option
- func WithBaseURL(url string) Option
- func WithConfig(cfg *config.Config) Option
- func WithDescription(description string) Option
- func WithFormat(format string) Option
- func WithOpenAPIOutput(path string) Option
- func WithOutput(path string) Option
- func WithTheme(theme string) Option
- func WithTitle(title string) Option
- func WithVersion(version string) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(endpoints []EndpointDef, opts ...Option) error
Generate creates documentation output from analyzed endpoints.
func GenerateOpenAPI ¶
func GenerateOpenAPI(endpoints []EndpointDef, opts ...Option) ([]byte, error)
GenerateOpenAPI generates an OpenAPI 3.1.0 spec from analyzed endpoints and returns the JSON bytes. Options Title and Version are used for the spec info.
Types ¶
type EndpointDef ¶
type EndpointDef = model.EndpointDef
EndpointDef is the public type alias for the analyzed endpoint contract.
func Analyze ¶
func Analyze(dir, pattern string, opts ...Option) ([]EndpointDef, error)
Analyze runs the analysis pipeline on the given Go packages and returns the extracted endpoint contracts. The pattern should be a directory path with an optional package pattern suffix (e.g. "./..." or "./cmd/...").
type Option ¶
type Option func(*Options)
Option is a functional option for configuring Analyze and Generate.
func WithBaseURL ¶
WithBaseURL sets the pre-filled base URL in Try It.
func WithConfig ¶
WithConfig sets the project configuration.
func WithDescription ¶
WithDescription sets the API description in the OpenAPI spec info block.
func WithFormat ¶
WithFormat sets the output format ("folder" or "single").
func WithOpenAPIOutput ¶
WithOpenAPIOutput sets the output path for an OpenAPI spec file.
func WithVersion ¶
WithVersion sets the project version displayed in the documentation.
type Options ¶
type Options struct {
Config *config.Config
OutputPath string
Format string // "folder" or "single"
Title string
Description string
Version string
BaseURL string
Theme string // "light" or "dark"
OpenAPIOutput string // path for OpenAPI spec output
}
Options configures the behavior of Analyze and Generate.