openapi

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator creates OpenAPI documentation from recorded API calls

func NewGenerator

func NewGenerator(storage proxy.Storage, title, description, version, basePath string) *Generator

NewGenerator creates a new generator

func (*Generator) Generate

func (g *Generator) Generate(outputPath string) error

Generate creates an OpenAPI specification from the recorded API calls

func (*Generator) SetTagMapping

func (g *Generator) SetTagMapping(pathPrefix, tag string)

SetTagMapping sets a custom tag mapping for paths with a specific prefix

func (*Generator) SetUsePathGroups

func (g *Generator) SetUsePathGroups(use bool)

SetUsePathGroups configures whether to group APIs by path segments

func (*Generator) SetVersionPrefix

func (g *Generator) SetVersionPrefix(prefix string)

SetVersionPrefix adds a custom version prefix for path handling

type OpenAPIConfig

type OpenAPIConfig struct {
	Title           string
	Description     string
	Version         string
	Servers         []OpenAPIServer
	TagMappings     map[string]string // Maps path prefixes to custom tags
	UsePathGroups   bool              // Whether to group APIs by path segments
	VersionPrefixes map[string]bool   // Custom version prefixes to detect
}

OpenAPIConfig holds configuration for the generator

type OpenAPIGenerator

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

OpenAPIGenerator generates OpenAPI specs from API transactions

func NewOpenAPIGenerator

func NewOpenAPIGenerator(config OpenAPIConfig) *OpenAPIGenerator

NewOpenAPIGenerator creates a new OpenAPI generator

func (*OpenAPIGenerator) AddTransaction

func (g *OpenAPIGenerator) AddTransaction(tx proxy.APITransaction)

AddTransaction adds an API transaction to be analyzed

func (*OpenAPIGenerator) GenerateSpec

func (g *OpenAPIGenerator) GenerateSpec() (*OpenAPISpec, error)

GenerateSpec generates an OpenAPI spec from the collected transactions

func (*OpenAPIGenerator) LoadTransactionsFromDirectory

func (g *OpenAPIGenerator) LoadTransactionsFromDirectory(dirPath string) error

LoadTransactionsFromDirectory loads API transactions from all JSON files in a directory

func (*OpenAPIGenerator) LoadTransactionsFromFile

func (g *OpenAPIGenerator) LoadTransactionsFromFile(filename string) error

LoadTransactionsFromFile loads API transactions from a file

type OpenAPIServer

type OpenAPIServer struct {
	URL         string
	Description string
}

OpenAPIServer represents an API server in the OpenAPI spec

type OpenAPISpec

type OpenAPISpec = openapi3.T

OpenAPISpec is an alias for openapi3.T to make it clearer

Jump to

Keyboard shortcuts

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