openapi

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildOperationContext

func BuildOperationContext(op *Operation) (string, error)

BuildOperationContext builds the operation context for system prompt

Types

type Operation

type Operation struct {
	Method      string                     `json:"method"`
	Path        string                     `json:"path"`
	OperationID string                     `json:"operationId,omitempty"`
	Summary     string                     `json:"summary,omitempty"`
	Description string                     `json:"description,omitempty"`
	Parameters  []Parameter                `json:"parameters,omitempty"`
	RequestBody *RequestBodySchema         `json:"requestBody,omitempty"`
	Response    *ResponseSchema            `json:"response,omitempty"`
	Responses   map[string]*ResponseSchema `json:"responses,omitempty"`
	RawSchema   map[string]any             `json:"rawResponseSchema,omitempty"`
}

Operation represents a parsed OpenAPI operation ready for routing

type Parameter

type Parameter struct {
	Name     string         `json:"name"`
	In       string         `json:"in"`
	Required bool           `json:"required"`
	Schema   map[string]any `json:"schema,omitempty"`
}

Parameter represents an OpenAPI parameter

type RequestBodySchema

type RequestBodySchema struct {
	Required bool           `json:"required"`
	Schema   map[string]any `json:"schema,omitempty"`
}

RequestBodySchema represents a POST request body

type ResponseSchema

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

ResponseSchema represents an HTTP response schema

type Spec

type Spec struct {
	Operations  []*Operation
	RawContent  []byte
	ContentType string // "json" or "yaml"
	Version     string
}

Spec holds the parsed OpenAPI specification

func LoadSpec

func LoadSpec(path string) (*Spec, error)

LoadSpec loads and parses an OpenAPI spec from a file

func (*Spec) ConvertToJSON

func (s *Spec) ConvertToJSON() ([]byte, error)

ConvertToJSON converts the spec to JSON if not already

func (*Spec) ServeContentType

func (s *Spec) ServeContentType() string

ServeContentType returns the content type header for the served spec

func (*Spec) ServeEndpoint

func (s *Spec) ServeEndpoint() string

ServeEndpoint returns the endpoint path for serving the spec

Jump to

Keyboard shortcuts

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