This file is indexed.

/usr/share/gocode/src/github.com/emicklei/go-restful/swagger/postbuild_model_test.go is in golang-github-emicklei-go-restful-dev 1.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
package swagger

import "testing"

type Boat struct {
	Length int `json:"-"` // on default, this makes the fields not required
	Weight int `json:"-"`
}

// PostBuildModel is from swagger.ModelBuildable
func (b Boat) PostBuildModel(m *Model) *Model {
	// override required
	m.Required = []string{"Length", "Weight"}

	// add model property (just to test is can be added; is this a real usecase?)
	extraType := "string"
	m.Properties.Put("extra", ModelProperty{
		Description: "extra description",
		DataTypeFields: DataTypeFields{
			Type: &extraType,
		},
	})
	return m
}

func TestCustomPostModelBuilde(t *testing.T) {
	testJsonFromStruct(t, Boat{}, `{
  "swagger.Boat": {
   "id": "swagger.Boat",
   "required": [
    "Length",
    "Weight"
   ],
   "properties": {
    "extra": {
     "type": "string",
     "description": "extra description"
    }
   }
  }
}`)
}