openapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwaggerUIHandler

func SwaggerUIHandler(specPath string) fiber.Handler

SwaggerUIHandler returns a Fiber handler that serves embedded Swagger UI. specPath is the URL where the openapi.json is located.

Types

type BuildInput

type BuildInput struct {
	Title       string
	Version     string
	Description string
	Contact     *Contact
	License     *License
	Servers     []ServerInfo
	Tags        []TagInfo
	Routes      []RouteInput
}

BuildInput groups the data to build the spec.

type Components

type Components struct {
	Schemas         map[string]any            `json:"schemas,omitempty"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}

Components groups reusable schemas and security schemes.

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	URL   string `json:"url,omitempty"`
	Email string `json:"email,omitempty"`
}

Contact holds API contact information.

type Info

type Info struct {
	Title       string   `json:"title"`
	Version     string   `json:"version"`
	Description string   `json:"description,omitempty"`
	Contact     *Contact `json:"contact,omitempty"`
	License     *License `json:"license,omitempty"`
}

type License

type License struct {
	Name string `json:"name"`
	URL  string `json:"url,omitempty"`
}

License holds API license information.

type QueryParamInput

type QueryParamInput struct {
	Name        string
	Type        string
	Description string
	Required    bool
}

QueryParamInput documents a query string parameter.

type RouteInput

type RouteInput struct {
	Method      string
	Path        string
	Summary     string
	Description string
	Tags        []string
	Secured     []string // security schemes: "bearerAuth", "apiKey", etc.
	Body        any
	Response    any
	StatusCode  int
	QueryParams []QueryParamInput
	Deprecated  bool
}

RouteInput is the neutral representation of a route.

type SecurityScheme

type SecurityScheme struct {
	Type         string `json:"type"`
	Scheme       string `json:"scheme,omitempty"`
	In           string `json:"in,omitempty"`
	Name         string `json:"name,omitempty"`
	BearerFormat string `json:"bearerFormat,omitempty"`
}

SecurityScheme defines an authentication scheme in OpenAPI.

type ServerInfo

type ServerInfo struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

ServerInfo describes an API server.

type Spec

type Spec struct {
	OpenAPI    string                `json:"openapi"`
	Info       Info                  `json:"info"`
	Servers    []ServerInfo          `json:"servers,omitempty"`
	Tags       []TagInfo             `json:"tags,omitempty"`
	Paths      map[string]any        `json:"paths"`
	Components Components            `json:"components"`
	Security   []map[string][]string `json:"security,omitempty"`
}

Spec is the in-memory representation of an OpenAPI 3.0 spec.

func Build

func Build(input BuildInput) Spec

Build constructs the OpenAPI 3.0 specification from the provided input.

type TagInfo

type TagInfo struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

TagInfo describes an OpenAPI tag with a description.

Jump to

Keyboard shortcuts

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