api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Type     AuthType
	Token    string // For bearer tokens
	APIKey   string // For API keys
	APIKeyIn string // header, query, cookie
	KeyName  string // Name of the header/query param
	Username string // For basic auth
	Password string // For basic auth
}

AuthConfig holds authentication configuration

type AuthManager

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

AuthManager manages authentication for API requests

func NewAuthManager

func NewAuthManager(spec *Spec) *AuthManager

NewAuthManager creates a new auth manager

func (*AuthManager) ApplyAuth

func (am *AuthManager) ApplyAuth(req *http.Request) error

ApplyAuth applies authentication to an HTTP request

func (*AuthManager) GetAuth

func (am *AuthManager) GetAuth() *AuthConfig

GetAuth returns current auth config

func (*AuthManager) GetAvailableAuthSchemes

func (am *AuthManager) GetAvailableAuthSchemes() []string

GetAvailableAuthSchemes returns available auth schemes from the spec

func (*AuthManager) ParseAuthScheme

func (am *AuthManager) ParseAuthScheme(schemeName string) (*AuthConfig, error)

ParseAuthScheme parses an auth scheme from the OpenAPI spec

func (*AuthManager) SetAuth

func (am *AuthManager) SetAuth(config *AuthConfig)

SetAuth configures authentication

type AuthType

type AuthType string

AuthType represents the type of authentication

const (
	AuthTypeNone   AuthType = "none"
	AuthTypeBearer AuthType = "bearer"
	AuthTypeAPIKey AuthType = "apikey"
	AuthTypeBasic  AuthType = "basic"
	AuthTypeOAuth2 AuthType = "oauth2"
)

type Client

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

Client handles HTTP requests to the API

func NewClient

func NewClient(baseURL string, authMgr *AuthManager) *Client

NewClient creates a new API client

func (*Client) Send

func (c *Client) Send(ctx context.Context, req *Request) *Response

Send sends an HTTP request

type Endpoint

type Endpoint struct {
	Path        string
	Method      string
	Summary     string
	Description string
	Tags        []string
	Parameters  []Parameter
	RequestBody string
	HasBody     bool
}

Endpoint represents an API endpoint

type Parameter

type Parameter struct {
	Name        string
	In          string // path, query, header, cookie
	Required    bool
	Description string
	Schema      string
	Example     string
}

Parameter represents a request parameter

type Request

type Request struct {
	Method      string
	Path        string
	Headers     map[string]string
	QueryParams map[string]string
	Body        string
	ContentType string
}

Request represents an API request

type Response

type Response struct {
	StatusCode int
	Status     string
	Headers    http.Header
	Body       string
	Duration   time.Duration
	Error      error
}

Response represents an API response

func (*Response) FormatResponseBody

func (r *Response) FormatResponseBody() string

FormatResponseBody formats the response body for display

type Spec

type Spec struct {
	Doc     *openapi3.T
	Source  string
	Title   string
	Version string
	BaseURL string
}

Spec wraps an OpenAPI specification with metadata

func (*Spec) GetEndpoints

func (s *Spec) GetEndpoints() []Endpoint

GetEndpoints extracts all endpoints from the spec

func (*Spec) GetInfo

func (s *Spec) GetInfo() (title, version, description string)

GetInfo returns basic spec information

Jump to

Keyboard shortcuts

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