Documentation
¶
Index ¶
- func Generate(c *contract.Contract, fsys fs.FS, gr *graph.Result) (string, error)
- func Serve(ctx context.Context, markdown, title string, port int) error
- func ServeOnListener(ctx context.Context, markdown, title string, ln net.Listener) error
- func ServeSwagger(ctx context.Context, opts SwaggerOptions) error
- func ServeSwaggerOnListener(ctx context.Context, opts SwaggerOptions, ln net.Listener) error
- type Endpoint
- type Property
- type SwaggerOptions
- type SwaggerSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate produces a Markdown document from a contract and its bundle filesystem. If gr is non-nil, the Mermaid diagram will show the full transitive dependency graph.
func Serve ¶
Serve starts a local HTTP server that renders the given markdown with GitHub-style styling using client-side marked.js. It blocks until the context is cancelled.
func ServeOnListener ¶
ServeOnListener is like Serve but accepts an existing net.Listener. This is useful in tests where port 0 is used to obtain a random port and the caller needs the address before blocking.
func ServeSwagger ¶
func ServeSwagger(ctx context.Context, opts SwaggerOptions) error
ServeSwagger starts a local HTTP server that renders an interactive API explorer (Scalar) for every HTTP interface that has an OpenAPI contract. It blocks until the context is cancelled.
func ServeSwaggerOnListener ¶
ServeSwaggerOnListener is like ServeSwagger but accepts an existing net.Listener. This is useful in tests where port 0 is used to obtain a random port and the caller needs the address before blocking.
Types ¶
type SwaggerOptions ¶
type SwaggerOptions struct {
Specs []SwaggerSpec
FS fs.FS
Title string
Port int
Target string // global target; applies to all interfaces
Targets map[string]string // per-interface targets; overrides Target
}
SwaggerOptions configures the interactive API explorer server.
type SwaggerSpec ¶
SwaggerSpec pairs an interface name with the path to its OpenAPI spec file.
func CollectSwaggerSpecs ¶
func CollectSwaggerSpecs(interfaces []contract.Interface) []SwaggerSpec
CollectSwaggerSpecs returns the HTTP interfaces that have an OpenAPI contract.
func FilterSpecs ¶
func FilterSpecs(specs []SwaggerSpec, name string) []SwaggerSpec
FilterSpecs returns only the spec matching the given interface name. It returns nil if no match is found.