doc

package
v0.25.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(c *contract.Contract, fsys fs.FS, gr *graph.Result) (string, error)

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

func Serve(ctx context.Context, markdown, title string, port int) error

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

func ServeOnListener(ctx context.Context, markdown, title string, ln net.Listener) error

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

func ServeSwaggerOnListener(ctx context.Context, opts SwaggerOptions, ln net.Listener) error

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.

func UnmarshalSpec added in v0.22.0

func UnmarshalSpec(data []byte, path string) (map[string]any, error)

UnmarshalSpec parses an OpenAPI spec as JSON (for .json files) or YAML.

Types

type Endpoint

type Endpoint struct {
	Method  string
	Path    string
	Summary string
}

Endpoint represents a single HTTP endpoint extracted from an OpenAPI spec.

func ReadOpenAPIEndpoints added in v0.22.0

func ReadOpenAPIEndpoints(fsys fs.FS, path string) ([]Endpoint, error)

ReadOpenAPIEndpoints parses an OpenAPI spec (YAML or JSON) and returns its endpoints sorted by path (alphabetically) then by HTTP method order.

type Property

type Property struct {
	Name        string
	Type        string
	Description string
	Default     string
	Required    bool
}

Property represents a configuration property extracted from a JSON Schema.

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

type SwaggerSpec struct {
	InterfaceName string
	SpecPath      string
}

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.

Jump to

Keyboard shortcuts

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