parser

package
v0.0.0-...-0d40b02 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package parser loads an OpenAPI 3.x spec and extracts a flat representation suited for static HTML rendering.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Description string
	Required    bool
	Content     []MediaType
}

Body is a request or response body.

type Doc

type Doc struct {
	Title       string
	Version     string
	Description string
	Servers     []string
	Tags        []TagGroup
}

Doc is the parsed representation of an OpenAPI spec, ready for rendering.

func Load

func Load(path string) (*Doc, error)

Load reads an OpenAPI 3.x document from path (JSON or YAML).

func LoadBytes

func LoadBytes(data []byte) (*Doc, error)

LoadBytes parses an OpenAPI 3.x document from in-memory bytes (JSON or YAML).

type Endpoint

type Endpoint struct {
	Method      string // uppercase: GET, POST, …
	Path        string
	Summary     string
	Description string
	Deprecated  bool
	Parameters  []Parameter
	RequestBody *Body
	Responses   []Response
}

Endpoint is a single HTTP operation.

type MediaType

type MediaType struct {
	Type   string // e.g. "application/json"
	Schema *Schema
}

MediaType is one content-type entry inside a body.

type Parameter

type Parameter struct {
	Name        string
	In          string // path, query, header, cookie
	Required    bool
	Description string
	Schema      *Schema
}

Parameter is a path/query/header/cookie parameter.

type Property

type Property struct {
	Name     string
	Required bool
	Schema   *Schema
}

Property is one named field inside an object schema.

type Response

type Response struct {
	Code        string
	Description string
	Content     []MediaType
}

Response is one HTTP response definition.

type Schema

type Schema struct {
	Type        string
	Format      string
	Description string
	Enum        []string
	Properties  []Property
	Items       *Schema // for array types
	Ref         string  // original $ref name if this was a reference
}

Schema is a simplified, recursion-resolved schema node for display.

type TagGroup

type TagGroup struct {
	Name        string
	Description string
	Endpoints   []Endpoint
}

TagGroup groups endpoints under a common tag (or "default" if untagged).

Jump to

Keyboard shortcuts

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