github.com/go-swagger/go-swagger@v0.31.0/docs/reference/annotations/params.md (about) 1 --- 2 title: params 3 date: 2023-01-01T01:01:01-08:00 4 draft: true 5 --- 6 # swagger:parameters 7 8 The **swagger:parameters** annotation links a struct to one or more operations. The parameters in the resulting swagger spec can be composed of several structs. 9 There are no guarantees given on how property name overlaps are resolved when several structs apply to the same operation. 10 This tag works very similarly to the swagger:model tag except that it produces valid parameter objects instead of schema 11 objects. 12 <!--more--> 13 When this appears anywhere in a comment for a struct, then that struct becomes a schema 14 in the definitions object of swagger. 15 16 The struct gets analyzed and all the collected models are added to the tree. 17 The refs are tracked separately so that they can be renamed later on. 18 19 At this moment the parameters require one or more structs to be defined, it's not possible to annotate plain var 20 entries at this moment. 21 22 ##### Syntax 23 24 ```go 25 swagger:parameters [operationid1 operationid2] 26 ``` 27 28 ##### Properties 29 30 The fields of this struct can be decorated with a number of annotations. For the field name it uses the struct field 31 name, it respects the json struct field tag for customizing the name. 32 33 Annotation | Format 34 **Items.*n*.Maximum** | specifies the maximum a number or integer value can have at the level *n* 35 **Items.*n*.Minimum** | specifies the minimum a number or integer value can have at the level *n* 36 **Items.*n*.Multiple of** | specifies a value a number or integer value must be a multiple of 37 **Items.*n*.Minimum length** | the minimum length for a string value at the level *n* 38 **Items.*n*.Maximum length** | the maximum length for a string value at the level *n* 39 **Items.*n*.Pattern** | a regular expression a string value needs to match at the level *n* 40 **Items.*n*.Minimum items** | the minimum number of items a slice needs to have at the level *n* 41 **Items.*n*.Maximum items** | the maximum number of items a slice can have at the level *n* 42 **Items.*n*.Unique** | when set to true the slice can only contain unique items at the level *n* 43 44 ##### Example 45 46 ```go 47 // swagger:parameters listBars addBars 48 type BarSliceParam struct { 49 // a BarSlice has bars which are strings 50 // 51 // min items: 3 52 // max items: 10 53 // unique: true 54 // items.minItems: 4 55 // items.maxItems: 9 56 // items.items.minItems: 5 57 // items.items.maxItems: 8 58 // items.items.items.minLength: 3 59 // items.items.items.maxLength: 10 60 // items.items.items.pattern: \w+ 61 // collection format: pipe 62 // in: query 63 // example: [[["bar_000"]]] 64 // Extensions: 65 // x-example-flag: true 66 // x-some-list: 67 // - dog 68 // - cat 69 // - bird 70 BarSlice [][][]string `json:"bar_slice"` 71 } 72 ``` 73 74 ##### Result 75 76 ```yaml 77 ```