Documentation
¶
Overview ¶
internal/docs/openapi.go
Index ¶
- func OpenAPIJSONHandler() http.HandlerFunc
- func SwaggerUIHandler() http.HandlerFunc
- type Components
- type Contact
- type Example
- type Header
- type Info
- type License
- type MediaType
- type OpenAPISpec
- type Operation
- type Parameter
- type PathItem
- type RequestBody
- type Response
- type Schema
- type SecurityRequirement
- type SecurityScheme
- type Server
- type ServerVariable
- type Tag
- type XMLObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenAPIJSONHandler ¶
func OpenAPIJSONHandler() http.HandlerFunc
OpenAPIJSONHandler returns an HTTP handler that serves the OpenAPI spec as JSON
func SwaggerUIHandler ¶
func SwaggerUIHandler() http.HandlerFunc
SwaggerUIHandler returns an HTTP handler that serves Swagger UI
Types ¶
type Components ¶
type Components struct {
Schemas map[string]Schema `json:"schemas,omitempty"`
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
Parameters map[string]Parameter `json:"parameters,omitempty"`
RequestBodies map[string]RequestBody `json:"requestBodies,omitempty"`
Responses map[string]Response `json:"responses,omitempty"`
}
Components container
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
Contact information
type Example ¶
type Example struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
}
Example for documentation
type Header ¶
type Header struct {
Description string `json:"description,omitempty"`
Schema *Schema `json:"schema,omitempty"`
}
Header definition
type Info ¶
type Info struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
Contact Contact `json:"contact,omitempty"`
License License `json:"license,omitempty"`
}
Info contains API metadata
type MediaType ¶
type MediaType struct {
Schema *Schema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
}
MediaType with schema
type OpenAPISpec ¶
type OpenAPISpec struct {
OpenAPI string `json:"openapi"`
Info Info `json:"info"`
Servers []Server `json:"servers,omitempty"`
Paths map[string]*PathItem `json:"paths"`
Components Components `json:"components"`
Security []SecurityRequirement `json:"security,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}
OpenAPISpec represents an OpenAPI 3.0 specification
func GenerateOpenAPISpec ¶
func GenerateOpenAPISpec() *OpenAPISpec
GenerateOpenAPISpec creates the complete OpenAPI specification
type Operation ¶
type Operation struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses map[string]Response `json:"responses"`
Security []SecurityRequirement `json:"security,omitempty"`
}
Operation represents an API operation
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Schema *Schema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
}
Parameter for operations
type PathItem ¶
type PathItem struct {
Get *Operation `json:"get,omitempty"`
Put *Operation `json:"put,omitempty"`
Post *Operation `json:"post,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Head *Operation `json:"head,omitempty"`
Options *Operation `json:"options,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
}
PathItem represents operations on a path
type RequestBody ¶
type RequestBody struct {
Description string `json:"description,omitempty"`
Content map[string]MediaType `json:"content"`
Required bool `json:"required,omitempty"`
}
RequestBody for operations
type Response ¶
type Response struct {
Description string `json:"description"`
Headers map[string]Header `json:"headers,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
}
Response from an operation
type Schema ¶
type Schema struct {
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Items *Schema `json:"items,omitempty"`
Example interface{} `json:"example,omitempty"`
Ref string `json:"$ref,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
XML *XMLObject `json:"xml,omitempty"`
}
Schema definition
type SecurityScheme ¶
type SecurityScheme struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
}
SecurityScheme definition
type Server ¶
type Server struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
Variables map[string]ServerVariable `json:"variables,omitempty"`
}
Server represents an API server
type ServerVariable ¶
type ServerVariable struct {
Default string `json:"default"`
Description string `json:"description,omitempty"`
Enum []string `json:"enum,omitempty"`
}
ServerVariable for templating