openapi

package
v0.2.16-rc.7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSchemas

func GetSchemas(schema *OpenAPISchema) map[string]SchemaProperty

Types

type ConfigSchema

type ConfigSchema struct {
	Sections []map[string]Section `yaml:"sections"`
}

type EndpointSchema

type EndpointSchema struct {
	Endpoint string `yaml:"endpoint"`
	Method   string `yaml:"method"`
	Schema   struct {
		Request  SchemaProperty `yaml:"request"`
		Response SchemaProperty `yaml:"response"`
	} `yaml:"schema"`
}

type ExtraHeader

type ExtraHeader struct {
	Values []string
}

ExtraHeader can be either string or []string

func (*ExtraHeader) UnmarshalYAML

func (h *ExtraHeader) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom unmarshaling for ExtraHeader

type ModelMap

type ModelMap struct {
	Source    string         `yaml:"source,omitempty"`
	Transform []TransformRef `yaml:"transform"`
}

type OpenAPISchema

type OpenAPISchema struct {
	Components struct {
		Schemas struct {
			Config struct {
				XConfig ConfigSchema `yaml:"x-config"`
			} `yaml:"Config"`
			Providers struct {
				XProviderConfigs map[string]ProviderConfig `yaml:"x-provider-configs"`
			} `yaml:"Providers"`
			AuthType         SchemaProperty `yaml:"AuthType"`
			Message          SchemaProperty `yaml:"Message"`
			Model            SchemaProperty `yaml:"Model"`
			ListResponse     SchemaProperty `yaml:"ListModelsResponse"`
			GenerateRequest  SchemaProperty `yaml:"GenerateRequest"`
			GenerateResponse SchemaProperty `yaml:"GenerateResponse"`
			ResponseToken    SchemaProperty `yaml:"ResponseTokens"`
		}
	}
}

OpenAPI schema structures

func Read

func Read(openapi string) (*OpenAPISchema, error)

type Property

type Property struct {
	Type        string              `yaml:"type"`
	Format      string              `yaml:"format,omitempty"`
	Description string              `yaml:"description,omitempty"`
	Ref         string              `yaml:"$ref,omitempty"`
	Enum        []string            `yaml:"enum,omitempty"`
	Properties  map[string]Property `yaml:"properties,omitempty"`
	Items       *Property           `yaml:"items,omitempty"`
}

type ProviderConfig

type ProviderConfig struct {
	ID           string                    `yaml:"id"`
	URL          string                    `yaml:"url"`
	AuthType     string                    `yaml:"auth_type"`
	ExtraHeaders map[string]ExtraHeader    `yaml:"extra_headers"`
	Endpoints    map[string]EndpointSchema `yaml:"endpoints"`
}

type ProviderEndpoints

type ProviderEndpoints struct {
	List     string `yaml:"list"`
	Generate string `yaml:"generate"`
}

type SchemaField

type SchemaField struct {
	Type       string                 `yaml:"type"`
	Properties map[string]SchemaField `yaml:"properties"`
	Items      *SchemaField           `yaml:"items"`
	Ref        string                 `yaml:"$ref"`
}

type SchemaProperty

type SchemaProperty struct {
	Type        string              `yaml:"type"`
	Description string              `yaml:"description"`
	Properties  map[string]Property `yaml:"properties"`
	Required    []string            `yaml:"required,omitempty"`
	Items       *Property           `yaml:"items,omitempty"`
	Enum        []string            `yaml:"enum,omitempty"`
	XTransform  *Transform          `yaml:"x-transform,omitempty"`
}

Structures for OpenAPI schema parsing

type Section

type Section struct {
	Title    string    `yaml:"title"`
	Settings []Setting `yaml:"settings"`
}

type Setting added in v0.1.10

type Setting struct {
	Env         string `yaml:"env"`
	Type        string `yaml:"type"`
	Default     string `yaml:"default,omitempty"`
	Description string `yaml:"description"`
	Secret      bool   `yaml:"secret,omitempty"`
}

type Transform

type Transform struct {
	Target  string       `yaml:"target"`
	Mapping TransformMap `yaml:"mapping"`
}

type TransformMap

type TransformMap struct {
	Provider string   `yaml:"provider"`
	Models   ModelMap `yaml:"models,omitempty"`
}

type TransformRef

type TransformRef struct {
	Source   string `yaml:"source,omitempty"`
	Target   string `yaml:"target"`
	Constant string `yaml:"constant,omitempty"`
}

Jump to

Keyboard shortcuts

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