openapi

package
v3.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package openapi parses OpenAPI specs (YAML or JSON) into a flat list of endpoints. It is a dependency-light leaf package so both the documentation generator (pkg/doc) and the dashboard (pkg/dashboard) can consume it without creating an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveOperationID

func DeriveOperationID(method, path string) string

DeriveOperationID builds a stable id from method+path when operationId is absent (e.g. GET /users/{id} -> get_users_id).

func UnmarshalSpec

func UnmarshalSpec(data []byte, path string) (map[string]any, error)

UnmarshalSpec parses an OpenAPI spec as JSON (for .json files) or YAML.

Types

type Doc

type Doc struct {
	Servers         []string
	SecuritySchemes map[string]SecurityScheme
	Security        []SecurityRequirement
	Components      map[string]any
	Operations      []Operation
}

Doc is the rich, parsed representation of an OpenAPI spec: enough to derive executable agent tools (operations, parameters, request bodies) and to authenticate against the live service (security schemes and requirements).

func ReadDoc

func ReadDoc(fsys fs.FS, path string) (*Doc, error)

ReadDoc parses an OpenAPI spec (YAML or JSON) into a rich Doc.

type Endpoint

type Endpoint struct {
	Method  string
	Path    string
	Summary string
}

Endpoint represents a single HTTP endpoint extracted from an OpenAPI spec.

func ReadOpenAPIEndpoints

func ReadOpenAPIEndpoints(fsys fs.FS, path string) ([]Endpoint, error)

ReadOpenAPIEndpoints parses an OpenAPI spec (YAML or JSON) and returns its endpoints sorted by path (alphabetically) then by HTTP method order.

type Operation

type Operation struct {
	ID          string
	Method      string
	Path        string
	Summary     string
	Description string
	Parameters  []Parameter
	RequestBody *RequestBody
	Security    []SecurityRequirement
}

Operation is a single method+path pair from the spec's paths.

type Parameter

type Parameter struct {
	Name        string
	In          string
	Description string
	Required    bool
	Schema      map[string]any
}

Parameter is a single OpenAPI operation parameter (path/query/header/cookie).

type RequestBody

type RequestBody struct {
	Required bool
	Schema   map[string]any
}

RequestBody holds the application/json request body schema for an operation.

type SecurityRequirement

type SecurityRequirement = map[string][]string

SecurityRequirement maps a scheme name to its required scopes.

type SecurityScheme

type SecurityScheme struct {
	Type         string
	In           string
	Name         string
	Scheme       string
	BearerFormat string
}

SecurityScheme describes a components.securitySchemes entry.

Jump to

Keyboard shortcuts

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