model

package
v0.6.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalPropertiesType

type AdditionalPropertiesType struct {
	Allowed *bool
	Schema  *SchemaRef
}

AdditionalPropertiesType represents the additionalProperties field. The additionalProperties field can either hold a boolean or a schema.

func (*AdditionalPropertiesType) IsAllowed

func (a *AdditionalPropertiesType) IsAllowed() bool

IsAllowed returns true when `additionalProperties: true`

func (AdditionalPropertiesType) MarshalJSON

func (a AdditionalPropertiesType) MarshalJSON() ([]byte, error)

func (*AdditionalPropertiesType) ToJSONSchemaProps added in v0.6.0

func (a *AdditionalPropertiesType) ToJSONSchemaProps(flattenBy *Document) *apiextensions.JSONSchemaPropsOrBool

func (*AdditionalPropertiesType) UnmarshalJSON

func (a *AdditionalPropertiesType) UnmarshalJSON(data []byte) (err error)

type Document

type Document struct {
	Schema `json:",inline"`

	SchemaVersion string                `json:"$schema,omitempty"`
	Definitions   map[string]*SchemaRef `json:"definitions,omitempty"`
}

Document represents a taxonomy schema document.

func (*Document) Deref

func (d *Document) Deref(in *SchemaRef) *SchemaRef

Deref dereferences a $ref to the schema model that it points to

func (*Document) ToFlatJSONSchemaProps added in v0.6.0

func (d *Document) ToFlatJSONSchemaProps() *apiextensions.JSONSchemaProps

ToFlatJSONSchemaProps creates a JSONSchemaProps from the definitions section in the document

func (*Document) ToJSONSchemaProps added in v0.6.0

func (d *Document) ToJSONSchemaProps() *apiextensions.JSONSchemaProps

ToJSONSchemaProps creates a JSONSchemaProps from the document

type Schema

type Schema struct {
	// Structure
	Type                 string                    `json:"type,omitempty"`
	Title                string                    `json:"title,omitempty"`
	Description          string                    `json:"description,omitempty"`
	Properties           Schemas                   `json:"properties,omitempty"`
	AdditionalProperties *AdditionalPropertiesType `json:"additionalProperties,omitempty"`
	Items                *SchemaRef                `json:"items,omitempty"`
	Default              *apiextensions.JSON       `json:"default,omitempty"`

	// Composable
	OneOf SchemaRefs `json:"oneOf,omitempty"`
	AnyOf SchemaRefs `json:"anyOf,omitempty"`
	AllOf SchemaRefs `json:"allOf,omitempty"`
	Not   *SchemaRef `json:"not,omitempty"`

	// Object
	Required []string `json:"required,omitempty"`
	MinProps *int64   `json:"minProperties,omitempty"`
	MaxProps *int64   `json:"maxProperties,omitempty"`

	// String
	Format    string               `json:"format,omitempty"`
	Enum      []apiextensions.JSON `json:"enum,omitempty"`
	MinLength *int64               `json:"minLength,omitempty"`
	MaxLength *int64               `json:"maxLength,omitempty"`
	Pattern   string               `json:"pattern,omitempty"`

	// Number
	Min          *float64 `json:"minimum,omitempty"`
	Max          *float64 `json:"maximum,omitempty"`
	MultipleOf   *float64 `json:"multipleOf,omitempty"`
	ExclusiveMin bool     `json:"exclusiveMinimum,omitempty"`
	ExclusiveMax bool     `json:"exclusiveMaximum,omitempty"`

	// Array
	MinItems    *int64 `json:"minItems,omitempty"`
	MaxItems    *int64 `json:"maxItems,omitempty"`
	UniqueItems bool   `json:"uniqueItems,omitempty"`
}

Schema is specified by OpenAPI/Swagger 3.0 standard The following fields are removed because they are not defined in JSON Schema DRAFT4 standard: Example, ExternalDocs, Nullable, ReadOnly, WriteOnly, AllowEmptyValue, XML, Deprecated, Discriminator.

func (*Schema) ToJSONSchemaProps added in v0.6.0

func (schema *Schema) ToJSONSchemaProps(flattenBy *Document) *apiextensions.JSONSchemaProps

type SchemaRef

type SchemaRef struct {
	Schema
	Ref string `json:"$ref,omitempty"`
}

SchemaRef is either a schema or a reference to a schema

func (*SchemaRef) RefName

func (schemaRef *SchemaRef) RefName() string

RefName returns the name from a reference. For example given a reference `$ref: "#/definitions/MyObject"`

the returned value is "MyObject".

func (*SchemaRef) ToJSONSchemaProps added in v0.6.0

func (schemaRef *SchemaRef) ToJSONSchemaProps(flattenBy *Document) *apiextensions.JSONSchemaProps

type SchemaRefs

type SchemaRefs []*SchemaRef

SchemaRefs is a list of schemas/references

func (*SchemaRefs) ToJSONSchemaProps added in v0.6.0

func (schemaRefs *SchemaRefs) ToJSONSchemaProps(flattenBy *Document) []apiextensions.JSONSchemaProps

type Schemas

type Schemas map[string]*SchemaRef

Schemas is a map of schemas/references

func (*Schemas) ToJSONSchemaProps added in v0.6.0

func (schemas *Schemas) ToJSONSchemaProps(flattenBy *Document) map[string]apiextensions.JSONSchemaProps

Jump to

Keyboard shortcuts

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