(document *loads.Document, schema *spec.Schema, dir string)
| 104 | } |
| 105 | |
| 106 | func parseSchema(document *loads.Document, schema *spec.Schema, dir string) (description string, structure map[string]*Parameter, example interface{}) { |
| 107 | def, _, ok := getDefinition(document, schema.Ref) |
| 108 | if !ok { |
| 109 | return |
| 110 | } |
| 111 | description = schema.Ref.Ref.GetPointer().String() |
| 112 | example = createSample(document, schema, dir) |
| 113 | structure = make(map[string]*Parameter, len(def.SchemaProps.Properties)) |
| 114 | for name, p := range def.SchemaProps.Properties { |
| 115 | par := &Parameter{ |
| 116 | Name: name, |
| 117 | Description: p.Title, |
| 118 | } |
| 119 | if len(p.Type) > 0 { |
| 120 | par.TypeName = p.Type[0] |
| 121 | } else { |
| 122 | par.TypeName = p.Ref.String() |
| 123 | } |
| 124 | structure[name] = par |
| 125 | } |
| 126 | return |
| 127 | } |
| 128 | |
| 129 | func createSample(document *loads.Document, data *spec.Schema, dir string, chain ...string) interface{} { |
| 130 | if refScheme, refName, ok := getDefinition(document, data.Ref); ok { |
no test coverage detected
searching dependent graphs…