merger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyRouting

func ApplyRouting(paths map[string]PathItem, manifest *farp.SchemaManifest) map[string]PathItem

ApplyRouting applies routing configuration to paths.

func GetSecuritySchemeSummary

func GetSecuritySchemeSummary(schemes map[string]SecurityScheme) string

GetSecuritySchemeSummary returns a summary of security schemes.

func MergeOperationSecurity

func MergeOperationSecurity(
	existingSecurity []map[string][]string,
	newSecurity []map[string][]string,
	strategy SecurityMergeStrategy,
) []map[string][]string

MergeOperationSecurity merges operation-level security requirements.

func PrefixTags

func PrefixTags(tags []string, prefix string) []string

PrefixTags adds prefix to operation tags.

func SortChannels

func SortChannels(channels map[string]Channel) []string

SortChannels sorts channels alphabetically.

func SortGRPCServices

func SortGRPCServices(services map[string]GRPCService) []string

SortGRPCServices sorts service names alphabetically.

func SortProcedures

func SortProcedures(procedures map[string]ORPCProcedure) []string

SortProcedures sorts procedure names alphabetically.

func ValidateSecurityScheme

func ValidateSecurityScheme(name string, scheme SecurityScheme) error

ValidateSecurityScheme validates a security scheme definition.

Types

type AsyncAPIMergeResult

type AsyncAPIMergeResult struct {
	Spec             *AsyncAPISpec
	IncludedServices []string
	ExcludedServices []string
	Conflicts        []Conflict
	Warnings         []string
}

AsyncAPIMergeResult contains the merged AsyncAPI spec and metadata.

type AsyncAPIMerger

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

AsyncAPIMerger handles AsyncAPI schema composition.

func NewAsyncAPIMerger

func NewAsyncAPIMerger(config MergerConfig) *AsyncAPIMerger

NewAsyncAPIMerger creates a new AsyncAPI merger.

func (*AsyncAPIMerger) MergeAsyncAPI

func (m *AsyncAPIMerger) MergeAsyncAPI(schemas []AsyncAPIServiceSchema) (*AsyncAPIMergeResult, error)

MergeAsyncAPI merges multiple AsyncAPI schemas from service manifests.

type AsyncAPIServiceSchema

type AsyncAPIServiceSchema struct {
	Manifest *farp.SchemaManifest
	Schema   any
	Parsed   *AsyncAPISpec
}

AsyncAPIServiceSchema wraps an AsyncAPI schema with its service context.

type AsyncAPISpec

type AsyncAPISpec struct {
	AsyncAPI   string                 `json:"asyncapi"`
	Info       Info                   `json:"info"`
	Servers    map[string]AsyncServer `json:"servers,omitempty"`
	Channels   map[string]Channel     `json:"channels"`
	Components *AsyncComponents       `json:"components,omitempty"`
	Security   []map[string][]string  `json:"security,omitempty"`
	Extensions map[string]any         `json:"-"`
}

AsyncAPISpec represents a simplified AsyncAPI 2.x/3.x specification.

func ParseAsyncAPISchema

func ParseAsyncAPISchema(raw any) (*AsyncAPISpec, error)

ParseAsyncAPISchema parses a raw AsyncAPI schema into structured format.

type AsyncComponents

type AsyncComponents struct {
	Messages        map[string]map[string]any      `json:"messages,omitempty"`
	Schemas         map[string]map[string]any      `json:"schemas,omitempty"`
	SecuritySchemes map[string]AsyncSecurityScheme `json:"securitySchemes,omitempty"`
}

AsyncComponents represents AsyncAPI components.

type AsyncSecurityScheme

type AsyncSecurityScheme struct {
	Type             string         `json:"type"` // userPassword, apiKey, X509, symmetricEncryption, asymmetricEncryption, httpApiKey, http, oauth2, openIdConnect
	Description      string         `json:"description,omitempty"`
	Name             string         `json:"name,omitempty"`             // For apiKey, httpApiKey
	In               string         `json:"in,omitempty"`               // For apiKey, httpApiKey: user, password, query, header, cookie
	Scheme           string         `json:"scheme,omitempty"`           // For http
	BearerFormat     string         `json:"bearerFormat,omitempty"`     // For http bearer
	OpenIdConnectURL string         `json:"openIdConnectUrl,omitempty"` // For openIdConnect
	Flows            map[string]any `json:"flows,omitempty"`            // For oauth2
}

AsyncSecurityScheme represents an AsyncAPI security scheme.

type AsyncServer

type AsyncServer struct {
	URL         string         `json:"url"`
	Protocol    string         `json:"protocol"` // kafka, amqp, mqtt, ws, etc.
	Description string         `json:"description,omitempty"`
	Variables   map[string]any `json:"variables,omitempty"`
	Bindings    map[string]any `json:"bindings,omitempty"`
}

AsyncServer represents an AsyncAPI server (broker connection).

type Channel

type Channel struct {
	Description string         `json:"description,omitempty"`
	Subscribe   *Operation     `json:"subscribe,omitempty"`
	Publish     *Operation     `json:"publish,omitempty"`
	Parameters  map[string]any `json:"parameters,omitempty"`
	Bindings    map[string]any `json:"bindings,omitempty"`
	Extensions  map[string]any `json:"-"`
}

Channel represents an AsyncAPI channel.

type Components

type Components struct {
	Schemas         map[string]map[string]any `json:"schemas,omitempty"`
	Responses       map[string]Response       `json:"responses,omitempty"`
	Parameters      map[string]Parameter      `json:"parameters,omitempty"`
	RequestBodies   map[string]RequestBody    `json:"requestBodies,omitempty"`
	Headers         map[string]Header         `json:"headers,omitempty"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}

Components represents OpenAPI components.

func PrefixComponentNames

func PrefixComponentNames(components *Components, prefix string) *Components

PrefixComponentNames adds prefix to component schema names.

type Conflict

type Conflict struct {
	// Type of conflict (path, component, tag, etc.)
	Type ConflictType

	// Path or name that conflicted
	Item string

	// Services involved in the conflict
	Services []string

	// How the conflict was resolved
	Resolution string

	// Conflict strategy that was applied
	Strategy farp.ConflictStrategy
}

Conflict represents a conflict encountered during merging.

type ConflictType

type ConflictType string

ConflictType represents the type of conflict.

const (
	// ConflictTypePath indicates path conflict.
	ConflictTypePath ConflictType = "path"

	// ConflictTypeComponent indicates component name conflict.
	ConflictTypeComponent ConflictType = "component"

	// ConflictTypeTag indicates tag conflict.
	ConflictTypeTag ConflictType = "tag"

	// ConflictTypeOperationID indicates operation ID conflict.
	ConflictTypeOperationID ConflictType = "operationId"

	// ConflictTypeSecurityScheme indicates security scheme conflict.
	ConflictTypeSecurityScheme ConflictType = "securityScheme"
)

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	URL   string `json:"url,omitempty"`
	Email string `json:"email,omitempty"`
}

Contact represents contact information.

type Example

type Example struct {
	Summary       string `json:"summary,omitempty"`
	Description   string `json:"description,omitempty"`
	Value         any    `json:"value,omitempty"`
	ExternalValue string `json:"externalValue,omitempty"`
}

Example represents an example object.

type GRPCEnum

type GRPCEnum struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Values      map[string]int `json:"values"`
}

GRPCEnum represents a protobuf enum.

type GRPCField

type GRPCField struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Number   int    `json:"number"`
	Repeated bool   `json:"repeated"`
	Optional bool   `json:"optional"`
}

GRPCField represents a message field.

type GRPCMergeResult

type GRPCMergeResult struct {
	Spec             *GRPCSpec
	IncludedServices []string
	ExcludedServices []string
	Conflicts        []Conflict
	Warnings         []string
}

GRPCMergeResult contains the merged gRPC spec and metadata.

type GRPCMerger

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

GRPCMerger handles gRPC schema composition.

func NewGRPCMerger

func NewGRPCMerger(config MergerConfig) *GRPCMerger

NewGRPCMerger creates a new gRPC merger.

func (*GRPCMerger) MergeGRPC

func (m *GRPCMerger) MergeGRPC(schemas []GRPCServiceSchema) (*GRPCMergeResult, error)

MergeGRPC merges multiple gRPC schemas from service manifests.

type GRPCMessage

type GRPCMessage struct {
	Name        string               `json:"name"`
	Description string               `json:"description,omitempty"`
	Fields      map[string]GRPCField `json:"fields"`
	Options     map[string]any       `json:"options,omitempty"`
}

GRPCMessage represents a protobuf message.

type GRPCMethod

type GRPCMethod struct {
	Name            string         `json:"name"`
	Description     string         `json:"description,omitempty"`
	InputType       string         `json:"input_type"`
	OutputType      string         `json:"output_type"`
	ClientStreaming bool           `json:"client_streaming"`
	ServerStreaming bool           `json:"server_streaming"`
	Options         map[string]any `json:"options,omitempty"`
}

GRPCMethod represents a gRPC method (RPC).

type GRPCSecurityScheme

type GRPCSecurityScheme struct {
	Type        string `json:"type"` // tls, oauth2, apiKey, custom
	Description string `json:"description,omitempty"`
	// TLS settings
	TLS *GRPCTLSConfig `json:"tls,omitempty"`
	// OAuth2 settings
	TokenURL string            `json:"tokenUrl,omitempty"`
	Scopes   map[string]string `json:"scopes,omitempty"`
	// API Key settings
	KeyName string `json:"keyName,omitempty"`
	// Custom metadata
	Metadata map[string]any `json:"metadata,omitempty"`
}

GRPCSecurityScheme represents gRPC authentication configuration.

type GRPCService

type GRPCService struct {
	Name        string                `json:"name"`
	Description string                `json:"description,omitempty"`
	Methods     map[string]GRPCMethod `json:"methods"`
	Options     map[string]any        `json:"options,omitempty"`
}

GRPCService represents a gRPC service definition.

type GRPCServiceSchema

type GRPCServiceSchema struct {
	Manifest *farp.SchemaManifest
	Schema   any
	Parsed   *GRPCSpec
}

GRPCServiceSchema wraps a gRPC schema with its service context.

type GRPCSpec

type GRPCSpec struct {
	Syntax          string                        `json:"syntax"` // proto3
	Package         string                        `json:"package"`
	Services        map[string]GRPCService        `json:"services"`
	Messages        map[string]GRPCMessage        `json:"messages"`
	Enums           map[string]GRPCEnum           `json:"enums,omitempty"`
	SecuritySchemes map[string]GRPCSecurityScheme `json:"securitySchemes,omitempty"`
	Imports         []string                      `json:"imports,omitempty"`
}

GRPCSpec represents a simplified gRPC service definition (protobuf-based).

func ParseGRPCSchema

func ParseGRPCSchema(raw any) (*GRPCSpec, error)

ParseGRPCSchema parses a raw gRPC schema into structured format.

type GRPCTLSConfig

type GRPCTLSConfig struct {
	ServerName         string `json:"serverName,omitempty"`
	RequireClientCert  bool   `json:"requireClientCert"`
	InsecureSkipVerify bool   `json:"insecureSkipVerify,omitempty"` // Dev only
}

GRPCTLSConfig represents TLS configuration for gRPC.

type Header struct {
	Description string         `json:"description,omitempty"`
	Schema      map[string]any `json:"schema,omitempty"`
}

Header represents a header object.

type Info

type Info struct {
	Title          string         `json:"title"`
	Description    string         `json:"description,omitempty"`
	Version        string         `json:"version"`
	TermsOfService string         `json:"termsOfService,omitempty"`
	Contact        *Contact       `json:"contact,omitempty"`
	License        *License       `json:"license,omitempty"`
	Extensions     map[string]any `json:"-"`
}

Info represents OpenAPI info object.

type License

type License struct {
	Name string `json:"name"`
	URL  string `json:"url,omitempty"`
}

License represents license information.

type MediaType

type MediaType struct {
	Schema   map[string]any     `json:"schema,omitempty"`
	Example  any                `json:"example,omitempty"`
	Examples map[string]Example `json:"examples,omitempty"`
}

MediaType represents a media type object.

type MergeResult

type MergeResult struct {
	// The merged OpenAPI specification
	Spec *OpenAPISpec

	// Services that were included in the merge
	IncludedServices []string

	// Services that were excluded (not marked for inclusion)
	ExcludedServices []string

	// Conflicts that were encountered during merge
	Conflicts []Conflict

	// Warnings (non-fatal issues)
	Warnings []string
}

MergeResult contains the merged OpenAPI spec and metadata.

type Merger

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

Merger handles OpenAPI schema composition.

func NewMerger

func NewMerger(config MergerConfig) *Merger

NewMerger creates a new OpenAPI merger.

func (*Merger) Merge

func (m *Merger) Merge(schemas []ServiceSchema) (*MergeResult, error)

Merge merges multiple OpenAPI schemas from service manifests.

type MergerConfig

type MergerConfig struct {
	// Default conflict strategy if not specified in metadata
	DefaultConflictStrategy farp.ConflictStrategy

	// Title for the merged OpenAPI spec
	MergedTitle string

	// Description for the merged OpenAPI spec
	MergedDescription string

	// Version for the merged OpenAPI spec
	MergedVersion string

	// Whether to include service tags in operations
	IncludeServiceTags bool

	// Whether to sort merged content alphabetically
	SortOutput bool

	// Custom server URLs for the merged spec
	Servers []Server
}

MergerConfig configures the merger behavior.

func DefaultMergerConfig

func DefaultMergerConfig() MergerConfig

DefaultMergerConfig returns default merger configuration.

type MultiProtocolMerger

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

MultiProtocolMerger handles composition of different schema types.

func NewMultiProtocolMerger

func NewMultiProtocolMerger(config MergerConfig) *MultiProtocolMerger

NewMultiProtocolMerger creates a new multi-protocol merger.

func (*MultiProtocolMerger) MergeAll

func (m *MultiProtocolMerger) MergeAll(manifests []*farp.SchemaManifest, schemaFetcher func(string) (any, error)) (*MultiProtocolResult, error)

MergeAll merges schemas across all protocols.

type MultiProtocolResult

type MultiProtocolResult struct {
	OpenAPI          *MergeResult
	AsyncAPI         *AsyncAPIMergeResult
	GRPC             *GRPCMergeResult
	ORPC             *ORPCMergeResult
	IncludedServices map[farp.SchemaType][]string
	Warnings         []string
}

MultiProtocolResult contains merged specs for all protocol types.

func (*MultiProtocolResult) GetSummary

func (r *MultiProtocolResult) GetSummary() string

GetSummary returns a summary of what was merged.

func (*MultiProtocolResult) GetTotalConflicts

func (r *MultiProtocolResult) GetTotalConflicts() int

GetTotalConflicts returns the total number of conflicts across all protocols.

func (*MultiProtocolResult) HasProtocol

func (r *MultiProtocolResult) HasProtocol(schemaType farp.SchemaType) bool

HasProtocol checks if a specific protocol was merged.

type ORPCError

type ORPCError struct {
	Code        int            `json:"code"`
	Message     string         `json:"message"`
	Description string         `json:"description,omitempty"`
	Schema      map[string]any `json:"schema,omitempty"`
}

ORPCError represents an error definition.

type ORPCMergeResult

type ORPCMergeResult struct {
	Spec             *ORPCSpec
	IncludedServices []string
	ExcludedServices []string
	Conflicts        []Conflict
	Warnings         []string
}

ORPCMergeResult contains the merged oRPC spec and metadata.

type ORPCMerger

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

ORPCMerger handles oRPC schema composition.

func NewORPCMerger

func NewORPCMerger(config MergerConfig) *ORPCMerger

NewORPCMerger creates a new oRPC merger.

func (*ORPCMerger) MergeORPC

func (m *ORPCMerger) MergeORPC(schemas []ORPCServiceSchema) (*ORPCMergeResult, error)

MergeORPC merges multiple oRPC schemas from service manifests.

type ORPCProcedure

type ORPCProcedure struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Input       *ORPCSchema    `json:"input,omitempty"`
	Output      *ORPCSchema    `json:"output,omitempty"`
	Errors      []ORPCError    `json:"errors,omitempty"`
	Streaming   bool           `json:"streaming,omitempty"`
	Batch       bool           `json:"batch,omitempty"`
	Options     map[string]any `json:"options,omitempty"`
	Extensions  map[string]any `json:"-"`
}

ORPCProcedure represents an oRPC procedure definition.

type ORPCSchema

type ORPCSchema struct {
	Ref    string         `json:"$ref,omitempty"`
	Type   string         `json:"type,omitempty"`
	Schema map[string]any `json:"schema,omitempty"`
}

ORPCSchema represents a schema reference or inline schema.

type ORPCSecurityScheme

type ORPCSecurityScheme struct {
	Type             string         `json:"type"` // apiKey, http, oauth2, openIdConnect
	Description      string         `json:"description,omitempty"`
	Name             string         `json:"name,omitempty"`             // For apiKey
	In               string         `json:"in,omitempty"`               // For apiKey: header, query, cookie
	Scheme           string         `json:"scheme,omitempty"`           // For http
	BearerFormat     string         `json:"bearerFormat,omitempty"`     // For http bearer
	OpenIdConnectURL string         `json:"openIdConnectUrl,omitempty"` // For openIdConnect
	Flows            map[string]any `json:"flows,omitempty"`            // For oauth2
}

ORPCSecurityScheme represents an oRPC security scheme.

type ORPCServiceSchema

type ORPCServiceSchema struct {
	Manifest *farp.SchemaManifest
	Schema   any
	Parsed   *ORPCSpec
}

ORPCServiceSchema wraps an oRPC schema with its service context.

type ORPCSpec

type ORPCSpec struct {
	ORPC            string                        `json:"orpc"`
	Info            Info                          `json:"info"`
	Servers         []Server                      `json:"servers,omitempty"`
	Procedures      map[string]ORPCProcedure      `json:"procedures"`
	Schemas         map[string]any                `json:"schemas,omitempty"`
	SecuritySchemes map[string]ORPCSecurityScheme `json:"securitySchemes,omitempty"`
	Security        []map[string][]string         `json:"security,omitempty"`
	Extensions      map[string]any                `json:"-"`
}

ORPCSpec represents a simplified oRPC specification.

func ParseORPCSchema

func ParseORPCSchema(raw any) (*ORPCSpec, error)

ParseORPCSchema parses a raw oRPC schema into structured format.

type OpenAPISpec

type OpenAPISpec struct {
	OpenAPI    string                `json:"openapi"`
	Info       Info                  `json:"info"`
	Servers    []Server              `json:"servers,omitempty"`
	Paths      map[string]PathItem   `json:"paths"`
	Components *Components           `json:"components,omitempty"`
	Security   []map[string][]string `json:"security,omitempty"`
	Tags       []Tag                 `json:"tags,omitempty"`
	Extensions map[string]any        `json:"-"` // x-* extensions
}

OpenAPISpec represents a simplified OpenAPI 3.x specification.

func ParseOpenAPISchema

func ParseOpenAPISchema(raw any) (*OpenAPISpec, error)

ParseOpenAPISchema parses a raw OpenAPI schema into structured format.

type Operation

type Operation struct {
	OperationID string                `json:"operationId,omitempty"`
	Summary     string                `json:"summary,omitempty"`
	Description string                `json:"description,omitempty"`
	Tags        []string              `json:"tags,omitempty"`
	Parameters  []Parameter           `json:"parameters,omitempty"`
	RequestBody *RequestBody          `json:"requestBody,omitempty"`
	Responses   map[string]Response   `json:"responses,omitempty"`
	Security    []map[string][]string `json:"security,omitempty"`
	Deprecated  bool                  `json:"deprecated,omitempty"`
	Extensions  map[string]any        `json:"-"`
}

Operation represents an OpenAPI operation.

type Parameter

type Parameter struct {
	Name        string         `json:"name"`
	In          string         `json:"in"` // query, header, path, cookie
	Description string         `json:"description,omitempty"`
	Required    bool           `json:"required,omitempty"`
	Schema      map[string]any `json:"schema,omitempty"`
	Example     any            `json:"example,omitempty"`
}

Parameter represents an OpenAPI parameter.

type PathItem

type PathItem struct {
	Summary     string         `json:"summary,omitempty"`
	Description string         `json:"description,omitempty"`
	Get         *Operation     `json:"get,omitempty"`
	Put         *Operation     `json:"put,omitempty"`
	Post        *Operation     `json:"post,omitempty"`
	Delete      *Operation     `json:"delete,omitempty"`
	Options     *Operation     `json:"options,omitempty"`
	Head        *Operation     `json:"head,omitempty"`
	Patch       *Operation     `json:"patch,omitempty"`
	Trace       *Operation     `json:"trace,omitempty"`
	Parameters  []Parameter    `json:"parameters,omitempty"`
	Extensions  map[string]any `json:"-"`
}

PathItem represents an OpenAPI path item.

type RequestBody

type RequestBody struct {
	Description string               `json:"description,omitempty"`
	Content     map[string]MediaType `json:"content"`
	Required    bool                 `json:"required,omitempty"`
	Extensions  map[string]any       `json:"-"`
}

RequestBody represents an OpenAPI request body.

type Response

type Response struct {
	Description string               `json:"description"`
	Content     map[string]MediaType `json:"content,omitempty"`
	Headers     map[string]Header    `json:"headers,omitempty"`
	Extensions  map[string]any       `json:"-"`
}

Response represents an OpenAPI response.

type SecurityConfig

type SecurityConfig struct {
	// Strategy for merging security schemes
	Strategy SecurityMergeStrategy

	// Global security to apply to all operations (overrides service-level)
	GlobalSecurity []map[string][]string

	// Whether to preserve operation-level security requirements
	PreserveOperationSecurity bool

	// Whether to prefix security scheme names with service name
	PrefixSchemeNames bool

	// Security schemes to exclude from merge
	ExcludeSchemes []string

	// Security schemes to always include
	RequiredSchemes []string
}

SecurityConfig configures security/auth merging behavior.

func DefaultSecurityConfig

func DefaultSecurityConfig() SecurityConfig

DefaultSecurityConfig returns default security configuration.

type SecurityConflict

type SecurityConflict struct {
	SchemeName      string
	Services        []string
	ConflictType    string // "definition", "type", "location"
	Resolution      string
	OriginalSchemes map[string]SecurityScheme
}

SecurityConflict represents a security scheme conflict.

type SecurityMergeInfo

type SecurityMergeInfo struct {
	// All security schemes found
	AllSchemes map[string]SecurityScheme

	// Security schemes by service
	SchemesByService map[string][]string

	// Common schemes across all services
	CommonSchemes []string

	// Conflicts found
	Conflicts []SecurityConflict

	// Applied strategy
	Strategy SecurityMergeStrategy
}

SecurityMergeInfo contains information about merged security.

func MergeSecuritySchemes

func MergeSecuritySchemes(
	serviceSchemas map[string]map[string]SecurityScheme,
	config SecurityConfig,
) (*SecurityMergeInfo, map[string]SecurityScheme, error)

MergeSecuritySchemes merges security schemes based on configuration.

type SecurityMergeStrategy

type SecurityMergeStrategy string

SecurityMergeStrategy defines how to handle security/auth during composition.

const (
	// SecurityStrategyUnion: Combine all security schemes, require ANY to pass.
	SecurityStrategyUnion SecurityMergeStrategy = "union"

	// SecurityStrategyIntersection: Only include common schemes, require ALL to pass.
	SecurityStrategyIntersection SecurityMergeStrategy = "intersection"

	// SecurityStrategyPerService: Keep service-specific security, prefix scheme names.
	SecurityStrategyPerService SecurityMergeStrategy = "per_service"

	// SecurityStrategyGlobal: Use a single global security definition.
	SecurityStrategyGlobal SecurityMergeStrategy = "global"

	// SecurityStrategyMostStrict: Use the most restrictive security from any service.
	SecurityStrategyMostStrict SecurityMergeStrategy = "most_strict"
)

type SecurityScheme

type SecurityScheme struct {
	Type             string `json:"type"` // apiKey, http, oauth2, openIdConnect
	Description      string `json:"description,omitempty"`
	Name             string `json:"name,omitempty"`             // For apiKey
	In               string `json:"in,omitempty"`               // For apiKey: query, header, cookie
	Scheme           string `json:"scheme,omitempty"`           // For http: bearer, basic
	BearerFormat     string `json:"bearerFormat,omitempty"`     // For http bearer
	OpenIdConnectURL string `json:"openIdConnectUrl,omitempty"` // For openIdConnect
}

SecurityScheme represents a security scheme.

type Server

type Server struct {
	URL         string                    `json:"url"`
	Description string                    `json:"description,omitempty"`
	Variables   map[string]ServerVariable `json:"variables,omitempty"`
}

Server represents an OpenAPI server.

type ServerVariable

type ServerVariable struct {
	Default     string   `json:"default"`
	Enum        []string `json:"enum,omitempty"`
	Description string   `json:"description,omitempty"`
}

ServerVariable represents a server variable.

type ServiceSchema

type ServiceSchema struct {
	Manifest *farp.SchemaManifest
	Schema   any // Raw OpenAPI schema (map[string]interface{})
	Parsed   *OpenAPISpec
}

ServiceSchema wraps a schema with its service context.

type Tag

type Tag struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Extensions  map[string]any `json:"-"`
}

Tag represents an OpenAPI tag.

func SortTags

func SortTags(tags []Tag) []Tag

SortTags sorts tags alphabetically.

Jump to

Keyboard shortcuts

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