-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.go
More file actions
23 lines (20 loc) · 696 Bytes
/
Copy pathjson.go
File metadata and controls
23 lines (20 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package openapi
import (
"encoding/json/jsontext"
"encoding/json/v2"
"github.com/MarkRosemaker/jsonutil"
)
var jsonOpts = json.JoinOptions([]json.Options{
// unevaluatedProperties is set to false in most objects according to the OpenAPI specification
// also protect against deleting unknown fields when overwriting later
json.RejectUnknownMembers(true),
json.WithMarshalers(json.JoinMarshalers(
json.MarshalToFunc(jsonutil.URLMarshal),
json.MarshalToFunc(patternMarshal),
)),
json.WithUnmarshalers(json.JoinUnmarshalers(
json.UnmarshalFromFunc(jsonutil.URLUnmarshal),
json.UnmarshalFromFunc(patternUnmarshal),
)),
jsontext.WithIndent(" "), // indent with two spaces
}...)