openapi

package
v0.0.0-...-2016107 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSchema

func GenerateSchema(sch thema.Schema, cfg *Config) (*ast.File, error)

GenerateSchema creates an OpenAPI document that represents the provided Thema Schema as an OpenAPI schema component.

Returns the result as a CUE AST, which is suitable for direct manipulation and marshaling to either JSON or YAML.

Types

type Config

type Config struct {
	*openapi.Config

	// Group indicates that the [thema.Schema] is from a grouped lineage - the root
	// schema itself does not represent an object that is ever expected to exist
	// independently, but each of its top-level fields do, including definitions and
	// optional fields.
	//
	// NOTE - https://github.com/grafana/thema/issues/62 is the issue for formalizing
	// the group concept. Fixing that issue will obviate this field. Once fixed,
	// this field will be deprecated and ignored.
	Group bool

	// RootName specifies the name to use for the type representing the root of the
	// schema. If empty, this defaults to titlecasing of the lineage name.
	//
	// No-op if [Group] is true.
	RootName string

	// Subpath specifies a path within the provided [thema.Schema] that should be
	// translated, rather than the root schema.
	//
	// No-op if [Group] is true.
	Subpath cue.Path

	// SplitSchema generates the schemas from schema and _join values, and it merges them
	// to generate the file. It's useful when their merged _#schema version doesn't show
	// the desired results.
	SplitSchema bool
}

Config controls OpenAPI derivation from a Thema schema.

Jump to

Keyboard shortcuts

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