Documentation ¶
Index ¶
- func EditSchema(schema *apiext.JSONSchemaProps, visitor SchemaVisitor)
- func FlattenEmbedded(schema *apiext.JSONSchemaProps, errRec ErrorRecorder) *apiext.JSONSchemaProps
- func NewGenerator() genall.Generator
- func RefParts(ref string) (typ string, pkgName string, err error)
- func TypeRefLink(pkgName, typeName string) string
- type ErrorRecorder
- type Flattener
- type PackageOverride
- type Parser
- type SchemaMarker
- type SchemaVisitor
- type TypeIdent
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 RefParts ¶
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 ¶
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 ¶
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 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.