apidoc

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = &APIRegistry{
	Routes: make(map[string]*RouteDoc),
}

Global Registry

Functions

func SwaggerUIHandler

func SwaggerUIHandler(swaggerJSONURL string) http.HandlerFunc

SwaggerUIHandler returns an http.HandlerFunc that serves Swagger UI HTML, configured to fetch the OpenAPI JSON specification from the given URL.

Types

type APIRegistry

type APIRegistry struct {
	Routes map[string]*RouteDoc
	Title  string
	Desc   string
	// contains filtered or unexported fields
}

func (*APIRegistry) GenerateOpenAPI

func (r *APIRegistry) GenerateOpenAPI() map[string]interface{}

GenerateOpenAPI returns the full OpenAPI 3.0 JSON structure

func (*APIRegistry) GetRoutes

func (r *APIRegistry) GetRoutes() []*RouteDoc

GetRoutes returns a thread-safe slice of all registered routes

func (*APIRegistry) Register

func (r *APIRegistry) Register(method, path string, doc *RouteDoc)

func (*APIRegistry) ToJSON

func (r *APIRegistry) ToJSON() ([]byte, error)

ToJSON returns the JSON bytes of the OpenAPI spec

type MediaTypeDoc

type MediaTypeDoc struct {
	Schema SchemaDoc `json:"schema"`
}

type ParamDoc

type ParamDoc struct {
	Name        string `json:"name"`
	In          string `json:"in"` // query, path, header
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required"`
	Type        string `json:"type"` // string, integer
}

type Property

type Property struct {
	Type string `json:"type"`
}

type RequestBodyDoc

type RequestBodyDoc struct {
	Content map[string]MediaTypeDoc `json:"content"`
}

type ResponseDoc

type ResponseDoc struct {
	Description string `json:"description"`
}

type RouteDoc

type RouteDoc struct {
	Method      string                 `json:"method"`
	Path        string                 `json:"path"`
	Summary     string                 `json:"summary"`
	Description string                 `json:"description"`
	Tags        []string               `json:"tags"`
	Params      []ParamDoc             `json:"parameters,omitempty"`
	RequestBody *RequestBodyDoc        `json:"requestBody,omitempty"`
	Responses   map[string]ResponseDoc `json:"responses"`
}

type SchemaDoc

type SchemaDoc struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties,omitempty"`
}

Jump to

Keyboard shortcuts

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