openapi

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllOperationIDs

func GetAllOperationIDs() (map[string]OperationIDInfo, error)

GetAllOperationIDs returns a map of all operation IDs found in all OpenAPI specs. The map key is the operation ID and the value is information about where it's defined. This is useful for validating operation IDs referenced in other parts of the codebase.

Example:

allOperationIDs, err := GetAllOperationIDs()
if err != nil {
    log.Fatalf("Failed to get operation IDs: %v", err)
}

// Check if a specific operation ID exists
if opInfo, exists := allOperationIDs["createProduct"]; exists {
    fmt.Printf("Operation found in %s at path %s using method %s\n",
        opInfo.SpecName, opInfo.Path, opInfo.Method)
}

// Print all operation IDs
for opID, opInfo := range allOperationIDs {
    fmt.Printf("%s: %s %s in %s\n", opID, opInfo.Method, opInfo.Path, opInfo.SpecName)
}

func GetAllSpecModels

func GetAllSpecModels() (map[string]*SpecModel, error)

GetAllSpecModels returns all available OpenAPI specs as libopenapi models

func GetOpenAPISpec

func GetOpenAPISpec(name string) ([]byte, error)

GetOpenAPISpec returns the content of an OpenAPI spec file by name

Types

type OperationIDInfo

type OperationIDInfo struct {
	SpecName string // Name of the OpenAPI spec file (without extension)
	Path     string // Path in the OpenAPI spec (e.g., "/v2/products/{id}")
	Method   string // HTTP method (e.g., "GET", "POST", etc.)
	Summary  string // Summary description of the operation
}

OperationIDInfo contains information about an operation ID and where it's defined

type OperationInfo

type OperationInfo struct {
	SpecName    string        // Name of the OpenAPI spec file (without extension)
	Path        string        // Path in the OpenAPI spec (e.g., "/v2/products/{id}")
	Method      string        // HTTP method (e.g., "GET", "POST", etc.)
	OperationID string        // The operationId from the OpenAPI spec
	Summary     string        // Summary description of the operation
	Operation   *v3.Operation // The actual OpenAPI v3 Operation object
}

OperationInfo represents information about an operation in an OpenAPI spec

func FindOperationByID

func FindOperationByID(operationID string) (*OperationInfo, error)

FindOperationByID searches all OpenAPI specs for an operation with the given ID and returns information about the operation if found.

Example:

opInfo, err := FindOperationByID("getProduct")
if err != nil {
    log.Fatalf("Operation not found: %v", err)
}
fmt.Printf("Found operation in %s at path %s using method %s\n",
    opInfo.SpecName, opInfo.Path, opInfo.Method)

type QueryParamInfo

type QueryParamInfo struct {
	Name        string
	EpccCliType string
}

func GetQueryParametersForOperation

func GetQueryParametersForOperation(operationID string) ([]*QueryParamInfo, error)

GetQueryParametersForOperation returns the query parameter names for a given operation ID

type SpecModel

type SpecModel struct {
	Name     string
	Document libopenapi.Document
	V3Model  v3.Document
}

SpecModel represents an OpenAPI spec model with its metadata

func GetSpecModel

func GetSpecModel(name string) (*SpecModel, error)

GetSpecModel returns a specific OpenAPI spec as a libopenapi model

type TagInfo

type TagInfo struct {
	Name        string
	Description string
}

func FindTagByName

func FindTagByName(tag string) (*TagInfo, string, error)

Jump to

Keyboard shortcuts

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