extension

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// When this config extension is redacted on the schema or this value is false, the underlining
	// JSON schema entity is expected to have its own validation endpoint. When left true, this hints
	// to our tests to skip asserting that a validation endpoint should exist for that entity.
	//
	// For example, when this value is false, for our `Consumer`
	// entity, it is expected that the below HTTP endpoint exists:
	// POST /v1/schemas/json/consumer/validate
	DisableValidateEndpoint bool `json:"disableValidateEndpoint"`

	// The resource's object name used in the REST API path. For example, for our `Consumer`
	// entity, this should be set to "consumers" as the REST path is `/v1/consumers`.
	//
	// This should be left empty in the event the resource is not exposed in the REST API.
	ResourceAPIPath string `json:"resourceAPIPath,omitempty"`
}

Config defines an internal-only vendor extension used to power various business logic around our JSON schema entities.

End-users do not see this extension when issuing calls to get a schema for a specific entity. As such, no properties on this extension shall be required.

func (*Config) Compile

func (c *Config) Compile(_ jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)

Compile implements the jsonschema.ExtCompiler interface.

func (*Config) Name

func (c *Config) Name() string

Name implements the Extension interface.

func (*Config) Schema

func (c *Config) Schema() *jsonschema.Schema

Schema implements the Extension interface.

func (*Config) Validate

func (c *Config) Validate(jsonschema.ValidationContext, interface{}) error

Validate implements the jsonschema.ExtSchema interface.

type Extension

type Extension interface {
	jsonschema.ExtCompiler

	// Name returns the name of the extension. This should match
	// the property named used on the JSON schema itself.
	Name() string

	// Schema returns the JSON schema for the extension.
	Schema() *jsonschema.Schema
}

Extension defines a simple interface to build out JSON schema extensions.

Jump to

Keyboard shortcuts

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