apiopenapi

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 12 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

View Source
const (
	MaxDocumentBytes = 10 << 20
)

Variables

This section is empty.

Functions

func BuildDocument

func BuildDocument(service models.APIService, routes []models.APIRoute, gatewayServer string) ([]byte, error)

BuildDocument rebuilds a standard OpenAPI document from current platform facts. Runtime upstreams and credentials are deliberately outside its input.

func RetainReachableComponents

func RetainReachableComponents(raw []byte) ([]byte, error)

RetainReachableComponents removes reusable components that are not reachable from the exported paths and document-level semantic references. The input must be an export already validated by ParseJSON, BuildDocument, or BuildExport; this function performs closure pruning, not full validation.

Types

type ImportBundle

type ImportBundle struct {
	Name        string                        `json:"name"`
	Description string                        `json:"description"`
	Document    models.OpenAPIServiceDocument `json:"document"`
	Servers     []models.OpenAPIServer        `json:"servers"`
	Routes      []ImportRoute                 `json:"routes"`
	Warnings    []Problem                     `json:"warnings"`
}

ImportBundle contains previewable, persistence-ready service document and Route drafts. Persistence and upstream selection belong to later layers.

func GroupRoutes

func GroupRoutes(document ParsedDocument, choices []RouteGroupChoice) (ImportBundle, error)

GroupRoutes groups paths by their first static segment, then applies any explicit preview choices. It does not interpret path-template parameters.

func (*ImportBundle) Route

func (b *ImportBundle) Route(slug string) *ImportRoute

Route finds a grouped Route by slug.

func (ImportBundle) RouteSlugs

func (b ImportBundle) RouteSlugs() []string

RouteSlugs returns stable lexical ordering, including an empty root slug.

type ImportRoute

type ImportRoute struct {
	models.APIRoute
	PublicPaths map[string]string `json:"public_paths"`
}

ImportRoute is a platform APIRoute draft plus the public path produced by its slug. PublicPaths is keyed by the original OpenAPI path.

type ParseError

type ParseError struct {
	Problems []Problem `json:"problems"`
}

ParseError reports all problems found while accepting an OpenAPI document.

func (*ParseError) Error

func (e *ParseError) Error() string

type ParsedDocument

type ParsedDocument struct {
	Name        string
	Description string
	Document    models.OpenAPIServiceDocument
	Paths       map[string]models.OpenAPIPathItem
}

ParsedDocument contains only platform-owned OpenAPI facts. The title and description remain separate because APIService owns them after import.

func ParseJSON

func ParseJSON(raw []byte) (ParsedDocument, error)

ParseJSON validates an OpenAPI 3.0/3.1 JSON document and converts it at the parser boundary into platform model types.

type Problem

type Problem struct {
	Path    string `json:"path"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

Problem is one safe, user-facing document problem located by JSON path.

type RouteGroupChoice

type RouteGroupChoice struct {
	Slug  string   `json:"slug"`
	Paths []string `json:"paths"`
}

RouteGroupChoice assigns complete OpenAPI paths to one confirmed Route slug. Paths omitted from choices keep their document-derived grouping.

Jump to

Keyboard shortcuts

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