openapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

type Components struct {
	Schemas map[string]*Schema `json:"schemas,omitempty"`
}

Components holds reusable objects

type MediaType

type MediaType struct {
	Schema *Schema `json:"schema,omitempty"`
}

MediaType provides schema and examples for the media type

type OpenAPIInfo

type OpenAPIInfo struct {
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	Version     string `json:"version"`
}

OpenAPIInfo represents API information

type OpenAPIResponse

type OpenAPIResponse struct {
	Description string               `json:"description"`
	Content     map[string]MediaType `json:"content,omitempty"`
}

OpenAPIResponse describes a single response in OpenAPI spec

type OpenAPISpec

type OpenAPISpec struct {
	OpenAPI    string              `json:"openapi"`
	Info       OpenAPIInfo         `json:"info"`
	Paths      map[string]PathItem `json:"paths"`
	Components *Components         `json:"components,omitempty"`
}

OpenAPISpec represents the OpenAPI 3.0 specification

type OpenApi

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

func NewOpenApi

func NewOpenApi(f *framework.Framework) *OpenApi

func (*OpenApi) GenerateOpenAPI

func (f *OpenApi) GenerateOpenAPI(title, description, version string) *OpenAPISpec

GenerateOpenAPI generates OpenAPI specification

func (*OpenApi) RegisterOpenAPIDocs

func (f *OpenApi) RegisterOpenAPIDocs(title, description, version, specPath, docsPath string) error

RegisterOpenAPIDocs registers the OpenAPI spec and Swagger UI endpoints This should be called after all other endpoints are registered

type Operation

type Operation struct {
	Summary     string                     `json:"summary,omitempty"`
	Description string                     `json:"description,omitempty"`
	Tags        []string                   `json:"tags,omitempty"`
	Parameters  []Parameter                `json:"parameters,omitempty"`
	RequestBody *RequestBody               `json:"requestBody,omitempty"`
	Responses   map[string]OpenAPIResponse `json:"responses"`
}

Operation describes a single API operation

type Parameter

type Parameter struct {
	Name        string  `json:"name"`
	In          string  `json:"in"` // query, header, path
	Description string  `json:"description,omitempty"`
	Required    bool    `json:"required"`
	Schema      *Schema `json:"schema"`
}

Parameter describes a single operation parameter

type PathItem

type PathItem struct {
	Get    *Operation `json:"get,omitempty"`
	Post   *Operation `json:"post,omitempty"`
	Put    *Operation `json:"put,omitempty"`
	Patch  *Operation `json:"patch,omitempty"`
	Delete *Operation `json:"delete,omitempty"`
}

PathItem represents operations available on a single path

type RequestBody

type RequestBody struct {
	Description string               `json:"description,omitempty"`
	Required    bool                 `json:"required"`
	Content     map[string]MediaType `json:"content"`
}

RequestBody describes a single request body

type Schema

type Schema struct {
	Type       string             `json:"type,omitempty"`
	Format     string             `json:"format,omitempty"`
	Properties map[string]*Schema `json:"properties,omitempty"`
	Required   []string           `json:"required,omitempty"`
	Items      *Schema            `json:"items,omitempty"`
	Ref        string             `json:"$ref,omitempty"`
	Enum       []interface{}      `json:"enum,omitempty"`
	Minimum    *float64           `json:"minimum,omitempty"`
	Maximum    *float64           `json:"maximum,omitempty"`
	MinLength  *int               `json:"minLength,omitempty"`
	MaxLength  *int               `json:"maxLength,omitempty"`
	Pattern    string             `json:"pattern,omitempty"`
}

Schema represents a data type

type SwaggerUIResponse

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

SwaggerUIResponse is a custom response that returns HTML

func (SwaggerUIResponse) WriteResponse

func (r SwaggerUIResponse) WriteResponse(w http.ResponseWriter)

WriteResponse implements the Responder interface for Swagger UI

Jump to

Keyboard shortcuts

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