Documentation ¶
Overview ¶
Package schema_validation contains all the logic, models and interfaces for validating OpenAPI 3+ Schemas. Functionality for validating individual *base.Schema instances, but as well as validating a complete OpenAPI 3+ document
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LocateSchemaPropertyNodeByJSONPath ¶
func LocateSchemaPropertyNodeByJSONPath(doc *yaml.Node, JSONPath string) *yaml.Node
LocateSchemaPropertyNodeByJSONPath will locate a schema property node by a JSONPath. It converts something like #/components/schemas/MySchema/properties/MyProperty to something like $.components.schemas.MySchema.properties.MyProperty
func ValidateOpenAPIDocument ¶
func ValidateOpenAPIDocument(doc libopenapi.Document) (bool, []*errors.ValidationError)
ValidateOpenAPIDocument will validate an OpenAPI 3+ document against the OpenAPI 3.0 schema. It will return true if the document is valid, false if it is not and a slice of ValidationError pointers. Swagger / OpenAPI 2.0 documents are not supported by this validator (and they won't be).
Types ¶
type SchemaValidator ¶
type SchemaValidator interface { // ValidateSchemaString accepts a schema object to validate against, and a JSON/YAML blob that is defined as a string. ValidateSchemaString(schema *base.Schema, payload string) (bool, []*errors.ValidationError) // ValidateSchemaObject accepts a schema object to validate against, and an object, created from unmarshalled JSON/YAML. // This is a pre-decoded object that will skip the need to unmarshal a string of JSON/YAML. ValidateSchemaObject(schema *base.Schema, payload interface{}) (bool, []*errors.ValidationError) // ValidateSchemaBytes accepts a schema object to validate against, and a byte slice containing a schema to // validate against. ValidateSchemaBytes(schema *base.Schema, payload []byte) (bool, []*errors.ValidationError) }
SchemaValidator is an interface that defines the methods for validating a *base.Schema (V3+ Only) object. There are 3 methods for validating a schema:
ValidateSchemaString accepts a schema object to validate against, and a JSON/YAML blob that is defined as a string. ValidateSchemaObject accepts a schema object to validate against, and an object, created from unmarshalled JSON/YAML. ValidateSchemaBytes accepts a schema object to validate against, and a JSON/YAML blob that is defined as a byte array.
func NewSchemaValidator ¶
func NewSchemaValidator() SchemaValidator
NewSchemaValidator will create a new SchemaValidator instance, ready to accept schemas and payloads to validate.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package openapi_schemas contains the OpenAPI 3.0 and 3.1 schemas that are loaded from libopenapi, or our own fork of the official OpenAPI repo specifications.
|
Package openapi_schemas contains the OpenAPI 3.0 and 3.1 schemas that are loaded from libopenapi, or our own fork of the official OpenAPI repo specifications. |