File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ Loop:
299299 )
300300 }
301301
302- if p .Tag .Optional {
302+ if p .Tag .Optional || p . Optional {
303303 wrapFuncChain = wrapFuncChain .Add (
304304 func (schema * spec.Schema ) * spec.Schema {
305305 spacer := ""
Original file line number Diff line number Diff line change @@ -121,6 +121,13 @@ var _ = Describe("ToSwaggerDefinition", func() {
121121 // W []string `json:"w"`
122122 // TT [][]string `json:"tt"`
123123 // }
124+ // type sampleRes struct {
125+ // Out1 int `json:"out1"`
126+ // Out2 string `json:"out2"`
127+ // Sub subRes `json:"sub"`
128+ // Subs []subRes `json:"subs"`
129+ // XSub *subRes `json:"xSub"`
130+ // }
124131
125132 d := swagger .ToSwaggerDefinition (ps .Contracts [0 ].Request .Message )
126133 props := d .Properties .ToOrderedSchemaItems ()
@@ -152,6 +159,9 @@ var _ = Describe("ToSwaggerDefinition", func() {
152159 Expect (props [3 ].Name ).To (Equal ("subs" ))
153160 Expect (props [3 ].SchemaProps .Type [0 ]).To (Equal ("array" ))
154161 Expect (props [3 ].SchemaProps .Items .Schema .Ref .String ()).To (Equal ("#/definitions/subRes" ))
162+ Expect (props [4 ].Name ).To (Equal ("xSub" ))
163+ Expect (props [4 ].SchemaProps .Ref .String ()).To (Equal ("#/definitions/subRes" ))
164+ Expect (props [4 ].SchemaProps .Description ).To (Equal ("[Optional]" ))
155165 })
156166
157167 It ("Check Request for Contract[1].Response (anotherRes)" , func () {
You can’t perform that action at this time.
0 commit comments