-
Notifications
You must be signed in to change notification settings - Fork 69
/
settings.go
53 lines (45 loc) · 1.08 KB
/
settings.go
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
51
52
53
package parser
import (
"net/url"
"github.com/ogen-go/ogen/jsonpointer"
"github.com/ogen-go/ogen/jsonschema"
"github.com/ogen-go/ogen/location"
)
// Settings is parser settings.
type Settings struct {
// External is external JSON Schema resolver. If nil, NoExternal resolver is used.
External jsonschema.ExternalResolver
// File is the file that is being parsed.
//
// Used for error messages.
File location.File
// RootURL is the root URL of the spec.
//
// If nil, jsonpointer.DummyURL is used.
RootURL *url.URL
// DepthLimit limits the number of nested references. Default is 1000.
DepthLimit int
// Enables type inference.
//
// For example:
//
// {
// "items": {
// "type": "string"
// }
// }
//
// In that case schemaParser will handle that schema as "array" schema, because it has "items" field.
InferTypes bool
}
func (s *Settings) setDefaults() {
if s.External == nil {
s.External = jsonschema.NoExternal{}
}
if s.DepthLimit == 0 {
s.DepthLimit = jsonpointer.DefaultDepthLimit
}
if s.RootURL == nil {
s.RootURL = jsonpointer.DummyURL()
}
}