Documentation
¶
Index ¶
Constants ¶
View Source
const ( // PropertyTypeNull represends nil values PropertyTypeNull = PropertyType("null") // PropertyTypeBoolean represends boolean values PropertyTypeBoolean = PropertyType("boolean") // PropertyTypeObject represends struct and map values PropertyTypeObject = PropertyType("object") // PropertyTypeArray represends slice and array values PropertyTypeArray = PropertyType("array") // PropertyTypeInteger represends int and uint values PropertyTypeInteger = PropertyType("integer") // PropertyTypeNumber represends float values PropertyTypeNumber = PropertyType("number") // PropertyTypeString represends string values PropertyTypeString = PropertyType("string") )
View Source
const ( // FormatDateTime derives from RFC 3339 FormatDateTime = Format("date-time") // FormatDate derives from RFC 3339 FormatDate = Format("date") // FormatTime derives from RFC 3339 FormatTime = Format("time") // FormatDuration derives from RFC 3339 FormatDuration = Format("duration") // FormatEmail as defined by the "Mailbox" ABNF rule in RFC 5321, section 4.1.2. FormatEmail = Format("email") // FormatIdnEmail as defined by the extended "Mailbox" ABNF rule in RFC 6531, section 3.3. FormatIdnEmail = Format("idn-email") // FormatHostname as defined by RFC 1123, section 2.1, including host names produced using the Punycode // algorithm specified in RFC 5891, section 4.4. FormatHostname = Format("hostname") // FormatIdnHostname as defined by either RFC 1123 as for hostname, or an internationalized hostname as defined // by RFC 5890, section 2.3.2.3. FormatIdnHostname = Format("idn-hostname") // FormatIPV4 is a ip version 4 FormatIPV4 = Format("ipv4") // FormatIPV6 is a ip version 6 FormatIPV6 = Format("ipv6") // FormatURI a valid uri derived from RFC3986 FormatURI = Format("uri") // FormatURIReference a valid uri derived from RFC3986 // either a URI or a relative-reference FormatURIReference = Format("uri-reference") // FormatIRI a valid uri derived from RFC3987 FormatIRI = Format("iri") // FormatIRIReference a valid uri derived from RFC3987 // either an IRI or a relative-reference FormatIRIReference = Format("iri-reference") // FormatUUID a valid uuid derived from RFC4122 FormatUUID = Format("uui") )
View Source
const VersionUsed = Version("https://json-schema.org/draft/2020-12/schema")
VersionUsed contains the schema version this package was build ontop
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Describe ¶
type Describe interface {
JSONSchemaDescribe() Property
}
Describe can be implmented by a type to manually describe the type
type Property ¶
type Property struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Type PropertyType `json:"type,omitempty"` // The data type Enum []json.RawMessage `json:"enum,omitempty"` // The value should validate againest one of these Const interface{} `json:"const,omitempty"` // Equal to a enum with 1 value Deprecated bool `json:"deprecated,omitempty"` Default interface{} `json:"default,omitempty"` Examples []json.RawMessage `json:"examples,omitempty"` Format Format `json:"format,omitempty"` Ref string `json:"$ref,omitempty"` Defs map[string]Property `json:"$defs,omitempty"` // Only in the root of the schema Schema Version `json:"$schema,omitempty"` ID string `json:"$id,omitempty"` // type == object Properties map[string]Property `json:"properties,omitempty"` // required field Required []string `json:"required,omitempty"` MaxProperties *uint `json:"maxProperties,omitempty"` MinProperties *uint `json:"minProperties,omitempty"` DependentRequired map[string][]string `json:"dependentRequired,omitempty"` // type == number || type == integer Minimum *int `json:"minimum,omitempty"` // >= Maximum *int `json:"maximum,omitempty"` // <= ExclusiveMinimum *int `json:"exclusiveMinimum,omitempty"` // > ExclusiveMaximum *int `json:"exclusiveMaximum,omitempty"` // < MultipleOf uint `json:"multipleOf,omitempty"` // type == array Items *Property `json:"items,omitempty"` // required field MinItems *uint `json:"minItems,omitempty"` MaxItems *uint `json:"maxItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` MaxContains *uint `json:"maxContains,omitempty"` MinContains *uint `json:"minContains,omitempty"` // type == string MaxLength *uint `json:"maxLength,omitempty"` MinLength *uint `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` // ECMA-262 regular expression }
Property represends a map / struct entry
func From ¶
func From( inputType interface{}, baseRefPath string, addRef func(key string, property Property), hasRef func(key string) bool, meta *WithMeta, ) (Property, error)
From converts a struct into a value for the properties part of a json schema baseRefPath might look something like #/components/schemas/
Click to show internal directories.
Click to hide internal directories.