...
1
2
3 package schutils
4
5 import (
6 "github.com/go-openapi/spec"
7 "github.com/go-openapi/swag"
8 )
9
10
11 func Save(sp *spec.Swagger, name string, schema *spec.Schema) {
12 if schema == nil {
13 return
14 }
15
16 if sp.Definitions == nil {
17 sp.Definitions = make(map[string]spec.Schema, 150)
18 }
19
20 sp.Definitions[name] = *schema
21 }
22
23
24 func Clone(schema *spec.Schema) *spec.Schema {
25 var sch spec.Schema
26 _ = swag.FromDynamicJSON(schema, &sch)
27
28 return &sch
29 }
30
View as plain text