respec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package respec provides a fluent API for adding OpenAPI metadata to http.HandlerFuncs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder holds the metadata provided by the developer through the fluent API.

func GetByHandler added in v0.2.0

func GetByHandler(handler types.Object) *Builder

GetByHandler is called by the static analyzer. It constructs a key from the analyzer's type information and uses it to look up the stored metadata.

func H added in v0.2.0

func H(handler http.HandlerFunc) *Builder

H wraps an http.HandlerFunc, allowing metadata to be chained to it. This is the main entry point for developers using the respec library. Usage: r.Post("/users", respec.H(myHandler).Tag("Users"))

func (*Builder) Description

func (b *Builder) Description(d string) *Builder

Description sets the description of the API endpoint.

func (*Builder) GetDescription

func (b *Builder) GetDescription() string

GetDescription returns the description of the API endpoint.

func (*Builder) GetParamModifiers

func (b *Builder) GetParamModifiers() map[string]ParamModifier

GetParamModifiers returns the parameter modifiers.

func (*Builder) GetSecurity

func (b *Builder) GetSecurity() []string

GetSecurity returns the security schemes associated with the API endpoint.

func (*Builder) GetSummary

func (b *Builder) GetSummary() string

GetSummary returns the summary of the API endpoint.

func (*Builder) GetTags

func (b *Builder) GetTags() []string

GetTags returns the tags associated with the API endpoint.

func (*Builder) OverrideParam

func (b *Builder) OverrideParam(name string, modifier ParamModifier) *Builder

OverrideParam provides a function to modify an inferred parameter. This is an advanced feature to gain fine-grained control over a parameter's definition.

func (*Builder) Security

func (b *Builder) Security(schemeName string) *Builder

Security adds a security scheme to the API endpoint. The name must match a key in the `securitySchemes` section of `.respec.yaml`.

func (*Builder) ServeHTTP added in v0.2.0

func (b *Builder) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows the Builder to satisfy the http.Handler interface. It simply calls the original handler, making the wrapper transparent at runtime.

func (*Builder) Summary

func (b *Builder) Summary(s string) *Builder

Summary sets the summary of the API endpoint.

func (*Builder) Tag

func (b *Builder) Tag(tags ...string) *Builder

Tag adds one or more tags to the API endpoint.

type ParamModifier

type ParamModifier func(p *openapi3.Parameter)

Modifier functions for granular control.

type ResponseModifier

type ResponseModifier func(r *openapi3.Response)

Jump to

Keyboard shortcuts

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