openapi

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 2 Imported by: 12

Documentation

Index

Constants

View Source
const (
	SecuritySchemeAPIKeyInQuery  = SecuritySchemeAPIKeyIn("query")
	SecuritySchemeAPIKeyInHeader = SecuritySchemeAPIKeyIn("header")
	SecuritySchemeAPIKeyInCookie = SecuritySchemeAPIKeyIn("cookie")
)

SecuritySchemeAPIKeyIn values enumeration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	OpenAPIVersion  string                     // OpenAPI version, e.g., "3.1.0"
	Title           string                     // Title of the API
	Version         string                     // Version of the API
	Description     *string                    // Optional description of the API
	Contact         *Contact                   // Contact information for the API
	License         *License                   // License information for the API
	Servers         []Server                   // List of servers for the API
	SecuritySchemes map[string]*SecurityScheme // Security schemes for the API
	Tags            []Tag                      // Tags for the API
	ExternalDocs    *ExternalDocs              // External documentation for the API

	ReflectorConfig *ReflectorConfig // Configuration for the OpenAPI reflector

	DisableOpenAPI bool
	BaseURL        string
	DocsPath       string
	SwaggerConfig  *SwaggerConfig
	Logger         Logger
}

Config holds the configuration for OpenAPI documentation generation.

type Contact

type Contact struct {
	Name          string
	URL           string         // Format: uri.
	Email         string         // Format: email.
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

Contact structure is generated from "#/$defs/contact".

type ExternalDocs

type ExternalDocs struct {
	Description string
	// Format: uri.
	// Required.
	URL           string
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

ExternalDocs structure is generated from "#/$defs/external-documentation".

type InterceptDefNameFunc

type InterceptDefNameFunc func(t reflect.Type, defaultDefName string) string

InterceptDefNameFunc is a function type for intercepting schema definition names.

type InterceptPropFunc

type InterceptPropFunc func(params InterceptPropParams) error

InterceptPropFunc is a function type for intercepting property schema generation.

type InterceptPropParams

type InterceptPropParams struct {
	Context        *jsonschema.ReflectContext
	Path           []string
	Name           string
	Field          reflect.StructField
	PropertySchema *jsonschema.Schema
	ParentSchema   *jsonschema.Schema
	Processed      bool
}

InterceptPropParams holds parameters for intercepting property schema generation.

type InterceptSchemaFunc

type InterceptSchemaFunc func(params InterceptSchemaParams) (stop bool, err error)

InterceptSchemaFunc is a function type for intercepting schema generation.

type InterceptSchemaParams

type InterceptSchemaParams struct {
	Context   *jsonschema.ReflectContext
	Value     reflect.Value
	Schema    *jsonschema.Schema
	Processed bool
}

InterceptSchemaParams holds parameters for intercepting schema generation.

type License

type License struct {
	Name          string // Required.
	Identifier    string
	URL           string         // Format: uri.
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

License structure is generated from "#/$defs/license".

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

Logger is an interface for logging.

type OAuthFlows

type OAuthFlows struct {
	Implicit          *OAuthFlowsDefsImplicit
	Password          *OAuthFlowsDefsPassword
	ClientCredentials *OAuthFlowsDefsClientCredentials
	AuthorizationCode *OAuthFlowsDefsAuthorizationCode
	MapOfAnything     map[string]any // Key must match pattern: `^x-`.
}

OAuthFlows structure is generated from "#/$defs/oauth-flows".

type OAuthFlowsDefsAuthorizationCode

type OAuthFlowsDefsAuthorizationCode struct {
	// Format: uri.
	// Required.
	AuthorizationURL string
	// Format: uri.
	// Required.
	TokenURL      string
	RefreshURL    *string           // Format: uri.
	Scopes        map[string]string // Required.
	MapOfAnything map[string]any    // Key must match pattern: `^x-`.
}

OAuthFlowsDefsAuthorizationCode structure is generated from "#/$defs/oauth-flows/$defs/authorization-code".

type OAuthFlowsDefsClientCredentials

type OAuthFlowsDefsClientCredentials struct {
	// Format: uri.
	// Required.
	TokenURL      string
	RefreshURL    *string           // Format: uri.
	Scopes        map[string]string // Required.
	MapOfAnything map[string]any    // Key must match pattern: `^x-`.
}

OAuthFlowsDefsClientCredentials structure is generated from "#/$defs/oauth-flows/$defs/client-credentials".

type OAuthFlowsDefsImplicit

type OAuthFlowsDefsImplicit struct {
	// Format: uri.
	// Required.
	AuthorizationURL string
	RefreshURL       *string           // Format: uri.
	Scopes           map[string]string // Required.
	MapOfAnything    map[string]any    // Key must match pattern: `^x-`.
}

OAuthFlowsDefsImplicit structure is generated from "#/$defs/oauth-flows/$defs/implicit".

type OAuthFlowsDefsPassword

type OAuthFlowsDefsPassword struct {
	// Format: uri.
	// Required.
	TokenURL      string
	RefreshURL    *string           // Format: uri.
	Scopes        map[string]string // Required.
	MapOfAnything map[string]any    // Key must match pattern: `^x-`.
}

OAuthFlowsDefsPassword structure is generated from "#/$defs/oauth-flows/$defs/password".

type ReflectorConfig

type ReflectorConfig struct {
	InlineRefs           bool                 // Whether to inline references in schemas
	RootRef              bool                 // Whether to use a root reference
	RootNullable         bool                 // Whether to allow root schemas to be nullable
	StripDefNamePrefix   []string             // Prefixes to strip from definition names
	InterceptDefNameFunc InterceptDefNameFunc // Function to customize schema definition names
	InterceptPropFunc    InterceptPropFunc    // Function to intercept property schema generation
	InterceptSchemaFunc  InterceptSchemaFunc  // Function to intercept schema generation
	TypeMappings         []TypeMapping        // Custom type mappings for OpenAPI generation
}

ReflectorConfig holds the configuration for the OpenAPI reflector.

type SecurityScheme

type SecurityScheme struct {
	Description   *string
	APIKey        *SecuritySchemeAPIKey
	HTTPBearer    *SecuritySchemeHTTPBearer
	OAuth2        *SecuritySchemeOAuth2
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

SecurityScheme structure is generated from "#/$defs/security-scheme".

type SecuritySchemeAPIKey

type SecuritySchemeAPIKey struct {
	Name string                 // Required.
	In   SecuritySchemeAPIKeyIn // Required.
}

SecuritySchemeAPIKey structure is generated from "#/$defs/security-scheme/$defs/type-apikey".

type SecuritySchemeAPIKeyIn

type SecuritySchemeAPIKeyIn string

SecuritySchemeAPIKeyIn is an enum type.

type SecuritySchemeHTTPBearer

type SecuritySchemeHTTPBearer struct {
	// Value must match pattern: `^[Bb][Ee][Aa][Rr][Ee][Rr]$`.
	// Required.
	Scheme       string  `json:"scheme"`
	BearerFormat *string `json:"bearerFormat,omitempty"`
}

SecuritySchemeHTTPBearer structure is generated from "#/$defs/security-scheme/$defs/type-http-bearer".

type SecuritySchemeOAuth2

type SecuritySchemeOAuth2 struct {
	Flows OAuthFlows // Required.
}

SecuritySchemeOAuth2 structure is generated from "#/$defs/security-scheme/$defs/type-oauth2".

type Server

type Server struct {
	// Format: uri-reference.
	// Required.
	URL           string
	Description   *string
	Variables     map[string]ServerVariable
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

Server structure is generated from "#/$defs/server".

type ServerVariable

type ServerVariable struct {
	Enum          []string
	Default       string // Required.
	Description   string
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

ServerVariable structure is generated from "#/$defs/server-variable".

type SwaggerConfig

type SwaggerConfig struct {
	ShowTopBar         bool
	HideCurl           bool
	JsonEditor         bool
	PreAuthorizeApiKey map[string]string

	// SettingsUI contains keys and plain javascript values of SwaggerUIBundle configuration.
	// Overrides default values.
	// See https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/ for available options.
	SettingsUI map[string]string

	// Proxy enables proxying requests through swgui handler.
	// Can be useful if API is not directly available due to CORS policy.
	Proxy bool
}

SwaggerConfig holds the configuration for Swagger UI.

type Tag

type Tag struct {
	Name          string // Required.
	Description   string
	ExternalDocs  *ExternalDocs
	MapOfAnything map[string]any // Key must match pattern: `^x-`.
}

Tag structure is generated from "#/definitions/Tag".

type TypeMapping

type TypeMapping struct {
	Src any // Source type
	Dst any // Destination type
}

TypeMapping holds a mapping between source and destination types.

Jump to

Keyboard shortcuts

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