api

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	BaseURL  string
	Auth     string
	AuthType string
	Headers  map[string]string
	Spec     string
	// contains filtered or unexported fields
}

func NewSession

func NewSession(cfg *config.API, opts ...SessionOption) (*Session, error)

func (*Session) Interactive

func (s *Session) Interactive() error

func (*Session) Request

func (s *Session) Request(method, path, body string, extra map[string]string) (string, error)

type SessionData added in v0.28.0

type SessionData struct {
	Cookies   []*http.Cookie    `json:"cookies"`
	AuthToken string            `json:"auth_token,omitempty"`
	AuthType  string            `json:"auth_type,omitempty"`
	Headers   map[string]string `json:"headers,omitempty"`
	SavedAt   time.Time         `json:"saved_at"`
}

SessionData represents the persisted session state.

type SessionOption added in v0.19.0

type SessionOption func(*Session)

func WithJqFilter added in v0.19.0

func WithJqFilter(filter string) SessionOption

WithJqFilter sets a jq filter for the session.

func WithSessionStore added in v0.28.0

func WithSessionStore(store *SessionStore) SessionOption

WithSessionStore enables HTTP session persistence for the session.

type SessionStore added in v0.28.0

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

SessionStore persists HTTP cookies and auth state across requests. It wraps an http.Client with a persistent cookie jar and provides methods for saving/loading session data to disk.

func NewSessionStore added in v0.28.0

func NewSessionStore(projectDir string) (*SessionStore, error)

NewSessionStore creates a new session store with cookies persisted to the given directory.

func (*SessionStore) Clear added in v0.28.0

func (s *SessionStore) Clear() error

Clear removes all persisted session data.

func (*SessionStore) CookieJar added in v0.28.0

func (s *SessionStore) CookieJar() http.CookieJar

CookieJar returns the persistent cookie jar for use with http.Client.

func (*SessionStore) GetAuth added in v0.28.0

func (s *SessionStore) GetAuth() (token, authType string)

GetAuth returns the persisted auth credentials.

func (*SessionStore) GetHeaders added in v0.28.0

func (s *SessionStore) GetHeaders() map[string]string

GetHeaders returns all persisted custom headers.

func (*SessionStore) SaveCookies added in v0.28.0

func (s *SessionStore) SaveCookies(_ string)

SaveCookies extracts cookies from the jar for a given URL and persists them.

func (*SessionStore) SetAuth added in v0.28.0

func (s *SessionStore) SetAuth(token, authType string)

SetAuth persists auth credentials in the session.

func (*SessionStore) SetHeader added in v0.28.0

func (s *SessionStore) SetHeader(key, value string)

SetHeader persists a custom header in the session.

func (*SessionStore) UpdateFromResponse added in v0.28.0

func (s *SessionStore) UpdateFromResponse(resp *http.Response, _ string)

UpdateFromResponse captures cookies and auth state from an HTTP response.

type Spec added in v0.25.0

type Spec struct {
	Title     string         `json:"title"`
	Version   string         `json:"version"`
	Endpoints []SpecEndpoint `json:"endpoints"`
}

Spec represents a parsed OpenAPI specification.

func ParseSpec added in v0.25.0

func ParseSpec(path string) (*Spec, error)

ParseSpec reads and parses an OpenAPI/Swagger spec file (YAML or JSON). Returns a structured Spec with all endpoints extracted.

func (*Spec) EndpointsByTag added in v0.25.0

func (s *Spec) EndpointsByTag() map[string][]SpecEndpoint

EndpointsByTag groups endpoints by their first tag.

func (*Spec) FindEndpoint added in v0.25.0

func (s *Spec) FindEndpoint(method, path string) *SpecEndpoint

FindEndpoint searches for an endpoint matching the given method and path. Path matching supports both exact match and parameterized paths like /users/{id}.

type SpecEndpoint added in v0.25.0

type SpecEndpoint struct {
	Method      string   `json:"method"`
	Path        string   `json:"path"`
	Summary     string   `json:"summary,omitempty"`
	OperationID string   `json:"operation_id,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

SpecEndpoint represents a single API endpoint parsed from an OpenAPI spec.

Jump to

Keyboard shortcuts

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