File: schemas.go

package info (click to toggle)
golang-github-flowstack-go-jsonschema 0.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,368 kB
  • sloc: makefile: 15
file content (50 lines) | stat: -rw-r--r-- 1,046 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package jsonschema

import (
	_ "embed"
	"fmt"
)

// TODO: Update with 20xx-xx props

var (
	//go:embed schemas/draft-04.json
	draft04Source []byte

	//go:embed schemas/draft-06.json
	draft06Source []byte

	//go:embed schemas/draft-07.json
	draft07Source []byte

	Draft04Schema *Schema
	Draft06Schema *Schema
	Draft07Schema *Schema
)

func init() {
	if draft04Source == nil {
		panic("can't start without schemas/draft-04.json")
	}
	if draft06Source == nil {
		panic("can't start without schemas/draft-06.json")
	}
	if draft07Source == nil {
		panic("can't start without schemas/draft-07.json")
	}

	var err error

	Draft04Schema, err = New(draft04Source)
	if err != nil {
		panic(fmt.Errorf("can't start without schemas/draft-04.json\n%s", err.Error()))
	}
	Draft06Schema, err = New(draft06Source)
	if err != nil {
		panic(fmt.Errorf("can't start without schemas/draft-06.json\n%s", err.Error()))
	}
	Draft07Schema, err = New(draft07Source)
	if err != nil {
		panic(fmt.Errorf("can't start without schemas/draft-07.json\n%s", err.Error()))
	}
}