openapi

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0, BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditSchema

func EditSchema(schema *apiext.JSONSchemaProps, visitor SchemaVisitor)

EditSchema walks the given schema using the given visitor. Actual pointers to each schema node are passed to the visitor, so any changes made by the visitor will be reflected to the passed-in schema.

func FlattenEmbedded

func FlattenEmbedded(schema *apiext.JSONSchemaProps, errRec ErrorRecorder) *apiext.JSONSchemaProps

FlattenEmbedded flattens embedded fields (represented via AllOf) which have already had their references resolved into simple properties in the containing schema.

func NewGenerator

func NewGenerator() genall.Generator

func RefParts

func RefParts(ref string) (typ string, pkgName string, err error)

RefParts splits a reference produced by the schema generator into its component type name and package name (if it's a cross-package reference). Note that referenced packages *must* be looked up relative to the current package.

func TypeRefLink(pkgName, typeName string) string

TypeRefLink creates a definition link for the given type and package.

Types

type ErrorRecorder

type ErrorRecorder interface {
	// AddError records that the given error occurred.
	// See the documentation on loader.Package.AddError for more information.
	AddError(error)
}

ErrorRecorder knows how to record errors. It wraps the part of pkg/loader.Package that we need to record errors in places were it might not make sense to have a loader.Package

type Flattener

type Flattener interface {
	FlattenType(typ TypeIdent) *apiext.JSONSchemaProps
}

type PackageOverride

type PackageOverride func(p *parser, pkg *loader.Package)

PackageOverride overrides the loading of some package (potentially setting custom schemata, etc). It must call AddPackage if it wants to continue with the default loading behavior.

type Parser

type Parser interface {
	// NeedPackage indicates that types and type-checking information
	// is needed for the given package.
	NeedPackage(pkg *loader.Package)
	NeedOpenAPIFor(typeIdent TypeIdent)
	FindProviderAPIs() []TypeIdent
	PrintSchemata()
}

func NewParser

func NewParser(ctx context.Context) Parser

type SchemaMarker

type SchemaMarker interface {
	// ApplyToSchema is called after the rest of the schema for a given type
	// or field is generated, to modify the schema appropriately.
	ApplyToSchema(*apiext.JSONSchemaProps) error
}

SchemaMarker is any marker that needs to modify the schema of the underlying type or field.

type SchemaVisitor

type SchemaVisitor interface {
	// Visit is called for each schema node.  If it returns a visitor,
	// the visitor will be called on each direct child node, and then
	// this visitor will be called again with `nil` to indicate that
	// all children have been visited.  If a nil visitor is returned,
	// children are not visited.
	//
	// It is *NOT* safe to save references to the given schema.
	// Make deepcopies if you need to keep things around beyond
	// the lifetime of the call.
	Visit(schema *apiext.JSONSchemaProps) SchemaVisitor
}

SchemaVisitor walks the nodes of a schema.

type TypeIdent

type TypeIdent struct {
	Package *loader.Package
	Name    string
}

TypeIdent represents some type in a Package.

func (TypeIdent) String

func (t TypeIdent) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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