openapi

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateForgeDescriptor

func CreateForgeDescriptor(router any, locationType farp.LocationType, locationConfig map[string]string) (*farp.SchemaDescriptor, error)

CreateForgeDescriptor creates a schema descriptor from a Forge router This is a helper method to simplify descriptor creation.

Types

type ForgeProvider

type ForgeProvider struct {
	*Provider
}

ForgeProvider is a Forge-specific OpenAPI provider that generates schemas from Forge's built-in OpenAPI generator.

func NewForgeProvider

func NewForgeProvider(specVersion string, endpoint string) *ForgeProvider

NewForgeProvider creates a new Forge-integrated OpenAPI provider.

func (*ForgeProvider) Generate

func (p *ForgeProvider) Generate(ctx context.Context, app farp.Application) (any, error)

Generate generates OpenAPI schema from Forge application.

func (*ForgeProvider) GenerateFromRouter

func (p *ForgeProvider) GenerateFromRouter(provider any) (any, error)

GenerateFromRouter generates OpenAPI schema directly from any type that provides OpenAPI specs This is a convenience method for direct router access.

func (*ForgeProvider) Validate

func (p *ForgeProvider) Validate(schema any) error

Validate validates an OpenAPI schema generated from Forge.

type OpenAPISchemaProvider

type OpenAPISchemaProvider interface {
	// OpenAPISchema returns a base OpenAPI schema (map[string]any) if the application provides one.
	// The returned schema will be merged with the generated schema.
	OpenAPISchema() map[string]any
}

OpenAPISchemaProvider is an optional interface that applications can implement to provide a base OpenAPI schema that will be merged with the generated schema.

type OpenAPISpecProvider

type OpenAPISpecProvider interface {
	OpenAPISpec() any
}

OpenAPISpecProvider is an interface for types that can provide an OpenAPI spec.

type Provider

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

Provider generates OpenAPI 3.x schemas from applications.

func NewProvider

func NewProvider(specVersion string, endpoint string) *Provider

NewProvider creates a new OpenAPI schema provider specVersion should be "3.0.0", "3.0.1", or "3.1.0" (recommended).

func (*Provider) ContentType

func (p *Provider) ContentType() string

ContentType returns the content type.

func (*Provider) Endpoint

func (p *Provider) Endpoint() string

Endpoint returns the HTTP endpoint where the schema is served.

func (*Provider) Generate

func (p *Provider) Generate(ctx context.Context, app farp.Application) (any, error)

Generate generates an OpenAPI schema from the application app should provide Routes() method that returns route information. If the app implements OpenAPISchemaProvider, the provided schema will be merged with the generated one.

func (*Provider) GenerateDescriptor

func (p *Provider) GenerateDescriptor(ctx context.Context, app farp.Application, locationType farp.LocationType, locationConfig map[string]string) (*farp.SchemaDescriptor, error)

GenerateDescriptor generates a complete SchemaDescriptor for this schema.

func (*Provider) Hash

func (p *Provider) Hash(schema any) (string, error)

Hash calculates SHA256 hash of the schema.

func (*Provider) Serialize

func (p *Provider) Serialize(schema any) ([]byte, error)

Serialize converts schema to JSON bytes.

func (*Provider) SpecVersion

func (p *Provider) SpecVersion() string

SpecVersion returns the OpenAPI specification version.

func (*Provider) Type

func (p *Provider) Type() farp.SchemaType

Type returns the schema type.

func (*Provider) Validate

func (p *Provider) Validate(schema any) error

Validate validates an OpenAPI schema.

Jump to

Keyboard shortcuts

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