github.com/livermorium/go-swagger@v0.19.0/generator/parameter_test.go (about)

     1  // Copyright 2015 go-swagger maintainers
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package generator
    16  
    17  import (
    18  	"bytes"
    19  	"fmt"
    20  	"io/ioutil"
    21  	"log"
    22  	"os"
    23  	"path"
    24  	"path/filepath"
    25  	"strings"
    26  	"testing"
    27  
    28  	"github.com/go-openapi/spec"
    29  	"github.com/go-openapi/swag"
    30  	"github.com/stretchr/testify/assert"
    31  )
    32  
    33  func TestBodyParams(t *testing.T) {
    34  	b, err := opBuilder("updateTask", "../fixtures/codegen/todolist.bodyparams.yml")
    35  
    36  	if !assert.NoError(t, err) {
    37  		t.FailNow()
    38  	}
    39  
    40  	_, _, op, ok := b.Analyzed.OperationForName("updateTask")
    41  	if assert.True(t, ok) && assert.NotNil(t, op) {
    42  		resolver := &typeResolver{ModelsPackage: b.ModelsPackage, Doc: b.Doc}
    43  		resolver.KnownDefs = make(map[string]struct{})
    44  		for k := range b.Doc.Spec().Definitions {
    45  			resolver.KnownDefs[k] = struct{}{}
    46  		}
    47  		for _, param := range op.Parameters {
    48  			if param.Name == "body" {
    49  				gp, perr := b.MakeParameter("a", resolver, param, nil)
    50  				if assert.NoError(t, perr) {
    51  					assert.True(t, gp.IsBodyParam())
    52  					if assert.NotNil(t, gp.Schema) {
    53  						assert.True(t, gp.Schema.IsComplexObject)
    54  						assert.False(t, gp.Schema.IsAnonymous)
    55  						assert.Equal(t, "models.Task", gp.Schema.GoType)
    56  					}
    57  				}
    58  			}
    59  		}
    60  	}
    61  
    62  	b, err = opBuilder("createTask", "../fixtures/codegen/todolist.bodyparams.yml")
    63  
    64  	if !assert.NoError(t, err) {
    65  		t.FailNow()
    66  	}
    67  
    68  	_, _, op, ok = b.Analyzed.OperationForName("createTask")
    69  	if assert.True(t, ok) && assert.NotNil(t, op) {
    70  		resolver := &typeResolver{ModelsPackage: b.ModelsPackage, Doc: b.Doc}
    71  		resolver.KnownDefs = make(map[string]struct{})
    72  		for k := range b.Doc.Spec().Definitions {
    73  			resolver.KnownDefs[k] = struct{}{}
    74  		}
    75  		for _, param := range op.Parameters {
    76  			if param.Name == "body" {
    77  				gp, err := b.MakeParameter("a", resolver, param, nil)
    78  				if assert.NoError(t, err) {
    79  					assert.True(t, gp.IsBodyParam())
    80  					if assert.NotNil(t, gp.Schema) {
    81  						assert.True(t, gp.Schema.IsComplexObject)
    82  						assert.False(t, gp.Schema.IsAnonymous)
    83  						assert.Equal(t, "CreateTaskBody", gp.Schema.GoType)
    84  
    85  						gpe, ok := b.ExtraSchemas["CreateTaskBody"]
    86  						assert.True(t, ok)
    87  						assert.True(t, gpe.IsComplexObject)
    88  						assert.False(t, gpe.IsAnonymous)
    89  						assert.Equal(t, "CreateTaskBody", gpe.GoType)
    90  					}
    91  				}
    92  			}
    93  		}
    94  	}
    95  }
    96  
    97  var arrayFormParams = []paramTestContext{
    98  	{"siBool", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatBool", "swag.ConvertBool", nil}},
    99  	{"siString", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"", "", nil}},
   100  	{"siNested", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"", "", &paramItemsTestContext{"", "", &paramItemsTestContext{"", "", nil}}}},
   101  	{"siInt", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatInt64", "swag.ConvertInt64", nil}},
   102  	{"siInt32", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatInt32", "swag.ConvertInt32", nil}},
   103  	{"siInt64", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatInt64", "swag.ConvertInt64", nil}},
   104  	{"siFloat", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatFloat64", "swag.ConvertFloat64", nil}},
   105  	{"siFloat32", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatFloat32", "swag.ConvertFloat32", nil}},
   106  	{"siFloat64", "arrayFormParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatFloat64", "swag.ConvertFloat64", nil}},
   107  }
   108  
   109  func TestFormArrayParams(t *testing.T) {
   110  	b, err := opBuilder("arrayFormParams", "../fixtures/codegen/todolist.arrayform.yml")
   111  
   112  	if !assert.NoError(t, err) {
   113  		t.FailNow()
   114  	}
   115  
   116  	for _, v := range arrayFormParams {
   117  		v.B = b
   118  		if !v.assertParameter(t) {
   119  			t.FailNow()
   120  		}
   121  	}
   122  }
   123  
   124  var arrayQueryParams = []paramTestContext{
   125  	{"siBool", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatBool", "swag.ConvertBool", nil}},
   126  	{"siString", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"", "", nil}},
   127  	{"siNested", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"", "", &paramItemsTestContext{"", "", &paramItemsTestContext{"", "", nil}}}},
   128  	{"siInt", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatInt64", "swag.ConvertInt64", nil}},
   129  	{"siInt32", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatInt32", "swag.ConvertInt32", nil}},
   130  	{"siInt64", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatInt64", "swag.ConvertInt64", nil}},
   131  	{"siFloat", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatFloat64", "swag.ConvertFloat64", nil}},
   132  	{"siFloat32", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatFloat32", "swag.ConvertFloat32", nil}},
   133  	{"siFloat64", "arrayQueryParams", "", "", codeGenOpBuilder{}, &paramItemsTestContext{"swag.FormatFloat64", "swag.ConvertFloat64", nil}},
   134  }
   135  
   136  func TestQueryArrayParams(t *testing.T) {
   137  	b, err := opBuilder("arrayQueryParams", "../fixtures/codegen/todolist.arrayquery.yml")
   138  
   139  	if !assert.NoError(t, err) {
   140  		t.FailNow()
   141  	}
   142  
   143  	for _, v := range arrayQueryParams {
   144  		v.B = b
   145  		if !v.assertParameter(t) {
   146  			t.FailNow()
   147  		}
   148  	}
   149  }
   150  
   151  var simplePathParams = []paramTestContext{
   152  	{"siBool", "simplePathParams", "swag.FormatBool", "swag.ConvertBool", codeGenOpBuilder{}, nil},
   153  	{"siString", "simplePathParams", "", "", codeGenOpBuilder{}, nil},
   154  	{"siInt", "simplePathParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   155  	{"siInt32", "simplePathParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   156  	{"siInt64", "simplePathParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   157  	{"siFloat", "simplePathParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   158  	{"siFloat32", "simplePathParams", "swag.FormatFloat32", "swag.ConvertFloat32", codeGenOpBuilder{}, nil},
   159  	{"siFloat64", "simplePathParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   160  }
   161  
   162  func TestSimplePathParams(t *testing.T) {
   163  	b, err := opBuilder("simplePathParams", "../fixtures/codegen/todolist.simplepath.yml")
   164  
   165  	if !assert.NoError(t, err) {
   166  		t.FailNow()
   167  	}
   168  	for _, v := range simplePathParams {
   169  		v.B = b
   170  		if !v.assertParameter(t) {
   171  			t.FailNow()
   172  		}
   173  	}
   174  }
   175  
   176  var simpleHeaderParams = []paramTestContext{
   177  	{"id", "simpleHeaderParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   178  	{"siBool", "simpleHeaderParams", "swag.FormatBool", "swag.ConvertBool", codeGenOpBuilder{}, nil},
   179  	{"siString", "simpleHeaderParams", "", "", codeGenOpBuilder{}, nil},
   180  	{"siInt", "simpleHeaderParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   181  	{"siInt32", "simpleHeaderParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   182  	{"siInt64", "simpleHeaderParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   183  	{"siFloat", "simpleHeaderParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   184  	{"siFloat32", "simpleHeaderParams", "swag.FormatFloat32", "swag.ConvertFloat32", codeGenOpBuilder{}, nil},
   185  	{"siFloat64", "simpleHeaderParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   186  }
   187  
   188  func TestSimpleHeaderParams(t *testing.T) {
   189  	b, err := opBuilder("simpleHeaderParams", "../fixtures/codegen/todolist.simpleheader.yml")
   190  
   191  	if !assert.NoError(t, err) {
   192  		t.FailNow()
   193  	}
   194  	for _, v := range simpleHeaderParams {
   195  		v.B = b
   196  		if !v.assertParameter(t) {
   197  			t.FailNow()
   198  		}
   199  	}
   200  }
   201  
   202  var simpleFormParams = []paramTestContext{
   203  	{"id", "simpleFormParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   204  	{"siBool", "simpleFormParams", "swag.FormatBool", "swag.ConvertBool", codeGenOpBuilder{}, nil},
   205  	{"siString", "simpleFormParams", "", "", codeGenOpBuilder{}, nil},
   206  	{"siInt", "simpleFormParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   207  	{"siInt32", "simpleFormParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   208  	{"siInt64", "simpleFormParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   209  	{"siFloat", "simpleFormParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   210  	{"siFloat32", "simpleFormParams", "swag.FormatFloat32", "swag.ConvertFloat32", codeGenOpBuilder{}, nil},
   211  	{"siFloat64", "simpleFormParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   212  }
   213  
   214  func TestSimpleFormParams(t *testing.T) {
   215  	b, err := opBuilder("simpleFormParams", "../fixtures/codegen/todolist.simpleform.yml")
   216  
   217  	if !assert.NoError(t, err) {
   218  		t.FailNow()
   219  	}
   220  	for _, v := range simpleFormParams {
   221  		v.B = b
   222  		if !v.assertParameter(t) {
   223  			t.FailNow()
   224  		}
   225  	}
   226  }
   227  
   228  var simpleQueryParams = []paramTestContext{
   229  	{"id", "simpleQueryParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   230  	{"siBool", "simpleQueryParams", "swag.FormatBool", "swag.ConvertBool", codeGenOpBuilder{}, nil},
   231  	{"siString", "simpleQueryParams", "", "", codeGenOpBuilder{}, nil},
   232  	{"siInt", "simpleQueryParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   233  	{"siInt32", "simpleQueryParams", "swag.FormatInt32", "swag.ConvertInt32", codeGenOpBuilder{}, nil},
   234  	{"siInt64", "simpleQueryParams", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   235  	{"siFloat", "simpleQueryParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   236  	{"siFloat32", "simpleQueryParams", "swag.FormatFloat32", "swag.ConvertFloat32", codeGenOpBuilder{}, nil},
   237  	{"siFloat64", "simpleQueryParams", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   238  }
   239  
   240  func TestSimpleQueryParamsAST(t *testing.T) {
   241  	b, err := opBuilder("simpleQueryParams", "../fixtures/codegen/todolist.simplequery.yml")
   242  
   243  	if !assert.NoError(t, err) {
   244  		t.FailNow()
   245  	}
   246  	for _, v := range simpleQueryParams {
   247  		v.B = b
   248  		if !v.assertParameter(t) {
   249  			t.FailNow()
   250  		}
   251  	}
   252  }
   253  
   254  type paramItemsTestContext struct {
   255  	Formatter string
   256  	Converter string
   257  	Items     *paramItemsTestContext
   258  }
   259  
   260  type paramTestContext struct {
   261  	Name      string
   262  	OpID      string
   263  	Formatter string
   264  	Converter string
   265  	B         codeGenOpBuilder
   266  	Items     *paramItemsTestContext
   267  }
   268  
   269  func (ctx *paramTestContext) assertParameter(t testing.TB) bool {
   270  	_, _, op, err := ctx.B.Analyzed.OperationForName(ctx.OpID)
   271  	if assert.True(t, err) && assert.NotNil(t, op) {
   272  		resolver := &typeResolver{ModelsPackage: ctx.B.ModelsPackage, Doc: ctx.B.Doc}
   273  		resolver.KnownDefs = make(map[string]struct{})
   274  		for k := range ctx.B.Doc.Spec().Definitions {
   275  			resolver.KnownDefs[k] = struct{}{}
   276  		}
   277  		for _, param := range op.Parameters {
   278  			if param.Name == ctx.Name {
   279  				gp, err := ctx.B.MakeParameter("a", resolver, param, nil)
   280  				if assert.NoError(t, err) {
   281  					return assert.True(t, ctx.assertGenParam(t, param, gp))
   282  				}
   283  			}
   284  		}
   285  		return false
   286  	}
   287  	return false
   288  }
   289  
   290  func (ctx *paramTestContext) assertGenParam(t testing.TB, param spec.Parameter, gp GenParameter) bool {
   291  	// went with the verbose option here, easier to debug
   292  	if !assert.Equal(t, param.In, gp.Location) {
   293  		return false
   294  	}
   295  	if !assert.Equal(t, param.Name, gp.Name) {
   296  		return false
   297  	}
   298  	if !assert.Equal(t, fmt.Sprintf("%q", param.Name), gp.Path) {
   299  		return false
   300  	}
   301  	if !assert.Equal(t, "i", gp.IndexVar) {
   302  		return false
   303  	}
   304  	if !assert.Equal(t, "a", gp.ReceiverName) {
   305  		return false
   306  	}
   307  	if !assert.Equal(t, "a."+swag.ToGoName(param.Name), gp.ValueExpression) {
   308  		return false
   309  	}
   310  	if !assert.Equal(t, ctx.Formatter, gp.Formatter) {
   311  		return false
   312  	}
   313  	if !assert.Equal(t, ctx.Converter, gp.Converter) {
   314  		return false
   315  	}
   316  	if !assert.Equal(t, param.Description, gp.Description) {
   317  		return false
   318  	}
   319  	if !assert.Equal(t, param.CollectionFormat, gp.CollectionFormat) {
   320  		return false
   321  	}
   322  	if !assert.Equal(t, param.Required, gp.Required) {
   323  		return false
   324  	}
   325  	if !assert.Equal(t, param.Minimum, gp.Minimum) || !assert.Equal(t, param.ExclusiveMinimum, gp.ExclusiveMinimum) {
   326  		return false
   327  	}
   328  	if !assert.Equal(t, param.Maximum, gp.Maximum) || !assert.Equal(t, param.ExclusiveMaximum, gp.ExclusiveMaximum) {
   329  		return false
   330  	}
   331  	if !assert.Equal(t, param.MinLength, gp.MinLength) {
   332  		return false
   333  	}
   334  	if !assert.Equal(t, param.MaxLength, gp.MaxLength) {
   335  		return false
   336  	}
   337  	if !assert.Equal(t, param.Pattern, gp.Pattern) {
   338  		return false
   339  	}
   340  	if !assert.Equal(t, param.MaxItems, gp.MaxItems) {
   341  		return false
   342  	}
   343  	if !assert.Equal(t, param.MinItems, gp.MinItems) {
   344  		return false
   345  	}
   346  	if !assert.Equal(t, param.UniqueItems, gp.UniqueItems) {
   347  		return false
   348  	}
   349  	if !assert.Equal(t, param.MultipleOf, gp.MultipleOf) {
   350  		return false
   351  	}
   352  	if !assert.EqualValues(t, param.Enum, gp.Enum) {
   353  		return false
   354  	}
   355  	if !assert.Equal(t, param.Type, gp.SwaggerType) {
   356  		return false
   357  	}
   358  	if !assert.Equal(t, param.Format, gp.SwaggerFormat) {
   359  		return false
   360  	}
   361  	if _, ok := primitives[gp.GoType]; ok {
   362  		if !assert.True(t, gp.IsPrimitive) {
   363  			return false
   364  		}
   365  	} else {
   366  		if !assert.False(t, gp.IsPrimitive) {
   367  			return false
   368  		}
   369  	}
   370  	// verify rendered template
   371  	if param.In == "body" {
   372  		return assertBodyParam(t, param, gp)
   373  	}
   374  
   375  	if ctx.Items != nil {
   376  		return ctx.Items.Assert(t, param.Items, gp.Child)
   377  	}
   378  
   379  	return true
   380  }
   381  
   382  func assertBodyParam(t testing.TB, param spec.Parameter, gp GenParameter) bool {
   383  	if !assert.Equal(t, "body", param.In) || !assert.Equal(t, "body", gp.Location) {
   384  		return false
   385  	}
   386  	if !assert.NotNil(t, gp.Schema) {
   387  		return false
   388  	}
   389  	return true
   390  }
   391  
   392  func (ctx *paramItemsTestContext) Assert(t testing.TB, pItems *spec.Items, gpItems *GenItems) bool {
   393  	if !assert.NotNil(t, pItems) || !assert.NotNil(t, gpItems) {
   394  		return false
   395  	}
   396  	// went with the verbose option here, easier to debug
   397  	if !assert.Equal(t, ctx.Formatter, gpItems.Formatter) {
   398  		return false
   399  	}
   400  	if !assert.Equal(t, ctx.Converter, gpItems.Converter) {
   401  		return false
   402  	}
   403  	if !assert.Equal(t, pItems.CollectionFormat, gpItems.CollectionFormat) {
   404  		return false
   405  	}
   406  	if !assert.Equal(t, pItems.Minimum, gpItems.Minimum) || !assert.Equal(t, pItems.ExclusiveMinimum, gpItems.ExclusiveMinimum) {
   407  		return false
   408  	}
   409  	if !assert.Equal(t, pItems.Maximum, gpItems.Maximum) || !assert.Equal(t, pItems.ExclusiveMaximum, gpItems.ExclusiveMaximum) {
   410  		return false
   411  	}
   412  	if !assert.Equal(t, pItems.MinLength, gpItems.MinLength) {
   413  		return false
   414  	}
   415  	if !assert.Equal(t, pItems.MaxLength, gpItems.MaxLength) {
   416  		return false
   417  	}
   418  	if !assert.Equal(t, pItems.Pattern, gpItems.Pattern) {
   419  		return false
   420  	}
   421  	if !assert.Equal(t, pItems.MaxItems, gpItems.MaxItems) {
   422  		return false
   423  	}
   424  	if !assert.Equal(t, pItems.MinItems, gpItems.MinItems) {
   425  		return false
   426  	}
   427  	if !assert.Equal(t, pItems.UniqueItems, gpItems.UniqueItems) {
   428  		return false
   429  	}
   430  	if !assert.Equal(t, pItems.MultipleOf, gpItems.MultipleOf) {
   431  		return false
   432  	}
   433  	if !assert.EqualValues(t, pItems.Enum, gpItems.Enum) {
   434  		return false
   435  	}
   436  	if !assert.Equal(t, pItems.Type, gpItems.SwaggerType) {
   437  		return false
   438  	}
   439  	if !assert.Equal(t, pItems.Format, gpItems.SwaggerFormat) {
   440  		return false
   441  	}
   442  	if ctx.Items != nil {
   443  		return ctx.Items.Assert(t, pItems.Items, gpItems.Child)
   444  	}
   445  	return true
   446  
   447  }
   448  
   449  var bug163Properties = []paramTestContext{
   450  	{"stringTypeInQuery", "getSearch", "", "", codeGenOpBuilder{}, nil},
   451  	{"numberTypeInQuery", "getSearch", "swag.FormatFloat64", "swag.ConvertFloat64", codeGenOpBuilder{}, nil},
   452  	{"integerTypeInQuery", "getSearch", "swag.FormatInt64", "swag.ConvertInt64", codeGenOpBuilder{}, nil},
   453  	{"booleanTypeInQuery", "getSearch", "swag.FormatBool", "swag.ConvertBool", codeGenOpBuilder{}, nil},
   454  }
   455  
   456  func TestGenParameters_Simple(t *testing.T) {
   457  	log.SetOutput(ioutil.Discard)
   458  	defer func() {
   459  		log.SetOutput(os.Stdout)
   460  	}()
   461  
   462  	b, err := opBuilder("getSearch", "../fixtures/bugs/163/swagger.yml")
   463  	if !assert.NoError(t, err) {
   464  		t.FailNow()
   465  	}
   466  	for _, v := range bug163Properties {
   467  		v.B = b
   468  		if !v.assertParameter(t) {
   469  			t.FailNow()
   470  		}
   471  	}
   472  }
   473  
   474  func TestGenParameter_Issue163(t *testing.T) {
   475  	log.SetOutput(ioutil.Discard)
   476  	defer func() {
   477  		log.SetOutput(os.Stdout)
   478  	}()
   479  
   480  	b, err := opBuilder("getSearch", "../fixtures/bugs/163/swagger.yml")
   481  	if assert.NoError(t, err) {
   482  		op, err := b.MakeOperation()
   483  		if assert.NoError(t, err) {
   484  			buf := bytes.NewBuffer(nil)
   485  			opts := opts()
   486  			err := templates.MustGet("serverParameter").Execute(buf, op)
   487  			if assert.NoError(t, err) {
   488  				ff, err := opts.LanguageOpts.FormatContent("get_search_parameters.go", buf.Bytes())
   489  				if assert.NoError(t, err) {
   490  					res := string(ff)
   491  					// NOTE(fredbi): removed default values resolution from private details (defaults are resolved in NewXXXParams())
   492  					assertInCode(t, "stringTypeInQueryDefault = string(\"qsValue\")", res)
   493  					assertInCode(t, "StringTypeInQuery: &stringTypeInQueryDefault", res)
   494  				} else {
   495  					fmt.Println(buf.String())
   496  				}
   497  			}
   498  		}
   499  	}
   500  }
   501  
   502  func TestGenParameter_Issue195(t *testing.T) {
   503  	log.SetOutput(ioutil.Discard)
   504  	defer func() {
   505  		log.SetOutput(os.Stdout)
   506  	}()
   507  
   508  	b, err := opBuilder("getTesting", "../fixtures/bugs/195/swagger.json")
   509  	if assert.NoError(t, err) {
   510  		op, err := b.MakeOperation()
   511  		if assert.NoError(t, err) {
   512  			buf := bytes.NewBuffer(nil)
   513  			opts := opts()
   514  			err := templates.MustGet("clientParameter").Execute(buf, op)
   515  			if assert.NoError(t, err) {
   516  				ff, err := opts.LanguageOpts.FormatContent("get_testing.go", buf.Bytes())
   517  				if assert.NoError(t, err) {
   518  					res := string(ff)
   519  					assertInCode(t, "TestingThis *int64", res)
   520  				} else {
   521  					fmt.Println(buf.String())
   522  				}
   523  			}
   524  		}
   525  	}
   526  }
   527  
   528  func TestGenParameter_Issue196(t *testing.T) {
   529  	log.SetOutput(ioutil.Discard)
   530  	defer func() {
   531  		log.SetOutput(os.Stdout)
   532  	}()
   533  
   534  	b, err := opBuilder("postEvents", "../fixtures/bugs/196/swagger.yml")
   535  	if assert.NoError(t, err) {
   536  		op, err := b.MakeOperation()
   537  		if assert.NoError(t, err) {
   538  			buf := bytes.NewBuffer(nil)
   539  			opts := opts()
   540  			err := templates.MustGet("serverParameter").Execute(buf, op)
   541  			if assert.NoError(t, err) {
   542  				ff, err := opts.LanguageOpts.FormatContent("post_events.go", buf.Bytes())
   543  				if assert.NoError(t, err) {
   544  					res := string(ff)
   545  					assertInCode(t, "body.Validate", res)
   546  				} else {
   547  					fmt.Println(buf.String())
   548  				}
   549  			}
   550  		}
   551  	}
   552  }
   553  
   554  func TestGenParameter_Issue217(t *testing.T) {
   555  	// Check for string
   556  
   557  	assertNoValidator(t, "postEcho", "../fixtures/bugs/217/string.yml")
   558  	assertNoValidator(t, "postEcho", "../fixtures/bugs/217/interface.yml")
   559  	assertNoValidator(t, "postEcho", "../fixtures/bugs/217/map.yml")
   560  	assertNoValidator(t, "postEcho", "../fixtures/bugs/217/array.yml")
   561  }
   562  
   563  func assertNoValidator(t testing.TB, opName, path string) {
   564  	b, err := opBuilder(opName, path)
   565  	if assert.NoError(t, err) {
   566  		op, err := b.MakeOperation()
   567  		if assert.NoError(t, err) {
   568  			var buf bytes.Buffer
   569  			opts := opts()
   570  			err := templates.MustGet("serverParameter").Execute(&buf, op)
   571  			if assert.NoError(t, err) {
   572  				ff, err := opts.LanguageOpts.FormatContent("post_echo.go", buf.Bytes())
   573  				if assert.NoError(t, err) {
   574  					res := string(ff)
   575  					assertNotInCode(t, "body.Validate", res)
   576  				} else {
   577  					fmt.Println(buf.String())
   578  				}
   579  			}
   580  		}
   581  	}
   582  }
   583  
   584  func TestGenParameter_Issue249(t *testing.T) {
   585  	b, err := opBuilder("putTesting", "../fixtures/bugs/249/swagger.json")
   586  	if assert.NoError(t, err) {
   587  		op, err := b.MakeOperation()
   588  		if assert.NoError(t, err) {
   589  			buf := bytes.NewBuffer(nil)
   590  			opts := opts()
   591  			err := templates.MustGet("clientParameter").Execute(buf, op)
   592  			if assert.NoError(t, err) {
   593  				ff, err := opts.LanguageOpts.FormatContent("put_testing.go", buf.Bytes())
   594  				if assert.NoError(t, err) {
   595  					res := string(ff)
   596  					assertNotInCode(t, "valuesTestingThis := o.TestingThis", res)
   597  				} else {
   598  					fmt.Println(buf.String())
   599  				}
   600  			}
   601  		}
   602  	}
   603  }
   604  
   605  func TestGenParameter_Issue248(t *testing.T) {
   606  	b, err := opBuilder("CreateThing", "../fixtures/bugs/248/swagger.json")
   607  	if assert.NoError(t, err) {
   608  		op, err := b.MakeOperation()
   609  		if assert.NoError(t, err) {
   610  			buf := bytes.NewBuffer(nil)
   611  			opts := opts()
   612  			err := templates.MustGet("serverParameter").Execute(buf, op)
   613  			if assert.NoError(t, err) {
   614  				ff, err := opts.LanguageOpts.FormatContent("create_thing.go", buf.Bytes())
   615  				if assert.NoError(t, err) {
   616  					res := string(ff)
   617  					assertInCode(t, ", *o.OptionalQueryEnum", res)
   618  				} else {
   619  					fmt.Println(buf.String())
   620  				}
   621  			}
   622  		}
   623  	}
   624  }
   625  
   626  func TestGenParameter_Issue350(t *testing.T) {
   627  	b, err := opBuilder("withBoolDefault", "../fixtures/codegen/todolist.allparams.yml")
   628  	if assert.NoError(t, err) {
   629  		op, err := b.MakeOperation()
   630  		if assert.NoError(t, err) {
   631  			buf := bytes.NewBuffer(nil)
   632  			opts := opts()
   633  			err := templates.MustGet("serverParameter").Execute(buf, op)
   634  			if assert.NoError(t, err) {
   635  				ff, err := opts.LanguageOpts.FormatContent("with_bool_default.go", buf.Bytes())
   636  				if assert.NoError(t, err) {
   637  					res := string(ff)
   638  					assertInCode(t, "Verbose: &verboseDefault", res)
   639  				} else {
   640  					fmt.Println(buf.String())
   641  				}
   642  			}
   643  		}
   644  	}
   645  }
   646  
   647  func TestGenParameter_Issue351(t *testing.T) {
   648  	b, err := opBuilder("withArray", "../fixtures/codegen/todolist.allparams.yml")
   649  	if assert.NoError(t, err) {
   650  		op, err := b.MakeOperation()
   651  		if assert.NoError(t, err) {
   652  			buf := bytes.NewBuffer(nil)
   653  			opts := opts()
   654  			err := templates.MustGet("serverParameter").Execute(buf, op)
   655  			if assert.NoError(t, err) {
   656  				ff, err := opts.LanguageOpts.FormatContent("with_array.go", buf.Bytes())
   657  				if assert.NoError(t, err) {
   658  					res := string(ff)
   659  					assertInCode(t, "validate.MinLength(fmt.Sprintf(\"%s.%v\", \"sha256\", i), \"query\", sha256I, 64)", res)
   660  				} else {
   661  					fmt.Println(buf.String())
   662  				}
   663  			}
   664  		}
   665  	}
   666  }
   667  
   668  func TestGenParameter_Issue511(t *testing.T) {
   669  	assert := assert.New(t)
   670  
   671  	gen, err := opBuilder("postModels", "../fixtures/bugs/511/swagger.yml")
   672  	if assert.NoError(err) {
   673  		op, err := gen.MakeOperation()
   674  		if assert.NoError(err) {
   675  			buf := bytes.NewBuffer(nil)
   676  			opts := opts()
   677  			err := templates.MustGet("serverParameter").Execute(buf, op)
   678  			if assert.NoError(err) {
   679  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   680  				if assert.NoError(err) {
   681  					res := string(ff)
   682  					assertNotInCode(t, "fds := runtime.Values(r.Form)", res)
   683  				} else {
   684  					fmt.Println(buf.String())
   685  				}
   686  			}
   687  		}
   688  	}
   689  }
   690  
   691  func TestGenParameter_Issue628_Collection(t *testing.T) {
   692  	assert := assert.New(t)
   693  
   694  	gen, err := opBuilder("collection", "../fixtures/bugs/628/swagger.yml")
   695  	if assert.NoError(err) {
   696  		op, err := gen.MakeOperation()
   697  		if assert.NoError(err) {
   698  			buf := bytes.NewBuffer(nil)
   699  			opts := opts()
   700  			err := templates.MustGet("serverParameter").Execute(buf, op)
   701  			if assert.NoError(err) {
   702  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   703  				if assert.NoError(err) {
   704  					res := string(ff)
   705  					assertInCode(t, `value, err := formats.Parse("uuid", workspaceIDIV)`, res) // NOTE(fredbi): added type assertion
   706  					assertInCode(t, `workspaceIDI := *(value.(*strfmt.UUID))`, res)
   707  					assertInCode(t, `workspaceIDIR = append(workspaceIDIR, workspaceIDI)`, res)
   708  				} else {
   709  					fmt.Println(buf.String())
   710  				}
   711  			}
   712  		}
   713  	}
   714  }
   715  
   716  func TestGenParameter_Issue628_Single(t *testing.T) {
   717  	assert := assert.New(t)
   718  
   719  	gen, err := opBuilder("single", "../fixtures/bugs/628/swagger.yml")
   720  	if assert.NoError(err) {
   721  		op, err := gen.MakeOperation()
   722  		if assert.NoError(err) {
   723  			buf := bytes.NewBuffer(nil)
   724  			opts := opts()
   725  			err := templates.MustGet("serverParameter").Execute(buf, op)
   726  			if assert.NoError(err) {
   727  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   728  				if assert.NoError(err) {
   729  					res := string(ff)
   730  					assertInCode(t, `value, err := formats.Parse("uuid", raw)`, res)
   731  					assertInCode(t, `o.WorkspaceID = *(value.(*strfmt.UUID))`, res)
   732  				} else {
   733  					fmt.Println(buf.String())
   734  				}
   735  			}
   736  		}
   737  	}
   738  }
   739  
   740  func TestGenParameter_Issue628_Details(t *testing.T) {
   741  	assert := assert.New(t)
   742  
   743  	gen, err := opBuilder("details", "../fixtures/bugs/628/swagger.yml")
   744  	if assert.NoError(err) {
   745  		op, err := gen.MakeOperation()
   746  		if assert.NoError(err) {
   747  			buf := bytes.NewBuffer(nil)
   748  			opts := opts()
   749  			err := templates.MustGet("serverParameter").Execute(buf, op)
   750  			if assert.NoError(err) {
   751  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   752  				if assert.NoError(err) {
   753  					res := string(ff)
   754  					assertInCode(t, `value, err := formats.Parse("uuid", raw)`, res)
   755  					assertInCode(t, `o.ID = *(value.(*strfmt.UUID))`, res)
   756  				} else {
   757  					fmt.Println(buf.String())
   758  				}
   759  			}
   760  		}
   761  	}
   762  }
   763  
   764  func TestGenParameter_Issue731_Collection(t *testing.T) {
   765  	assert := assert.New(t)
   766  
   767  	gen, err := opBuilder("collection", "../fixtures/bugs/628/swagger.yml")
   768  	if assert.NoError(err) {
   769  		op, err := gen.MakeOperation()
   770  		if assert.NoError(err) {
   771  			buf := bytes.NewBuffer(nil)
   772  			opts := opts()
   773  			err := templates.MustGet("clientParameter").Execute(buf, op)
   774  			if assert.NoError(err) {
   775  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   776  				if assert.NoError(err) {
   777  					res := string(ff)
   778  					assertInCode(t, `for _, v := range o.WorkspaceID`, res)
   779  					assertInCode(t, `valuesWorkspaceID = append(valuesWorkspaceID, v.String())`, res)
   780  					assertInCode(t, `joinedWorkspaceID := swag.JoinByFormat(valuesWorkspaceID, "")`, res)
   781  				} else {
   782  					fmt.Println(buf.String())
   783  				}
   784  			}
   785  		}
   786  	}
   787  }
   788  
   789  func TestGenParameter_Issue731_Single(t *testing.T) {
   790  	assert := assert.New(t)
   791  
   792  	gen, err := opBuilder("single", "../fixtures/bugs/628/swagger.yml")
   793  	if assert.NoError(err) {
   794  		op, err := gen.MakeOperation()
   795  		if assert.NoError(err) {
   796  			buf := bytes.NewBuffer(nil)
   797  			opts := opts()
   798  			err := templates.MustGet("clientParameter").Execute(buf, op)
   799  			if assert.NoError(err) {
   800  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   801  				if assert.NoError(err) {
   802  					res := string(ff)
   803  					assertInCode(t, `qWorkspaceID := qrWorkspaceID.String()`, res)
   804  					assertInCode(t, `r.SetQueryParam("workspace_id", qWorkspaceID)`, res)
   805  				} else {
   806  					fmt.Println(buf.String())
   807  				}
   808  			}
   809  		}
   810  	}
   811  }
   812  
   813  func TestGenParameter_Issue731_Details(t *testing.T) {
   814  	assert := assert.New(t)
   815  
   816  	gen, err := opBuilder("details", "../fixtures/bugs/628/swagger.yml")
   817  	if assert.NoError(err) {
   818  		op, err := gen.MakeOperation()
   819  		if assert.NoError(err) {
   820  			buf := bytes.NewBuffer(nil)
   821  			opts := opts()
   822  			err := templates.MustGet("clientParameter").Execute(buf, op)
   823  			if assert.NoError(err) {
   824  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   825  				if assert.NoError(err) {
   826  					res := string(ff)
   827  					assertInCode(t, `r.SetPathParam("id", o.ID.String())`, res)
   828  				} else {
   829  					fmt.Println(buf.String())
   830  				}
   831  			}
   832  		}
   833  	}
   834  }
   835  
   836  func TestGenParameter_Issue809_Client(t *testing.T) {
   837  	assert := assert.New(t)
   838  
   839  	gen, err := methodPathOpBuilder("get", "/foo", "../fixtures/bugs/809/swagger.yml")
   840  	if assert.NoError(err) {
   841  		op, err := gen.MakeOperation()
   842  		if assert.NoError(err) {
   843  			buf := bytes.NewBuffer(nil)
   844  			opts := opts()
   845  			err := templates.MustGet("clientParameter").Execute(buf, op)
   846  			if assert.NoError(err) {
   847  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   848  				if assert.NoError(err) {
   849  					res := string(ff)
   850  					assertInCode(t, "valuesGroups", res)
   851  				} else {
   852  					fmt.Println(buf.String())
   853  				}
   854  			}
   855  		}
   856  	}
   857  }
   858  
   859  func TestGenParameter_Issue809_Server(t *testing.T) {
   860  	assert := assert.New(t)
   861  
   862  	gen, err := methodPathOpBuilder("get", "/foo", "../fixtures/bugs/809/swagger.yml")
   863  	if assert.NoError(err) {
   864  		op, err := gen.MakeOperation()
   865  		if assert.NoError(err) {
   866  			buf := bytes.NewBuffer(nil)
   867  			opts := opts()
   868  			err := templates.MustGet("serverParameter").Execute(buf, op)
   869  			if assert.NoError(err) {
   870  				ff, err := opts.LanguageOpts.FormatContent("post_models.go", buf.Bytes())
   871  				if assert.NoError(err) {
   872  					res := string(ff)
   873  					assertInCode(t, "groupsIC := rawData", res)
   874  				} else {
   875  					fmt.Println(buf.String())
   876  				}
   877  			}
   878  		}
   879  	}
   880  }
   881  
   882  func TestGenParameter_Issue1010_Server(t *testing.T) {
   883  	assert := assert.New(t)
   884  
   885  	gen, err := methodPathOpBuilder("get", "/widgets/", "../fixtures/bugs/1010/swagger.yml")
   886  	if assert.NoError(err) {
   887  		op, err := gen.MakeOperation()
   888  		if assert.NoError(err) {
   889  			buf := bytes.NewBuffer(nil)
   890  			opts := opts()
   891  			err := templates.MustGet("serverParameter").Execute(buf, op)
   892  			if assert.NoError(err) {
   893  				ff, err := opts.LanguageOpts.FormatContent("get_widgets.go", buf.Bytes())
   894  				if assert.NoError(err) {
   895  					res := string(ff)
   896  					assertInCode(t, "validate.Pattern(fmt.Sprintf(\"%s.%v\", \"category_id\", i), \"query\", categoryIDI, `^[0-9abcdefghjkmnpqrtuvwxyz]{29}$`)", res)
   897  				} else {
   898  					fmt.Println(buf.String())
   899  				}
   900  			}
   901  		}
   902  	}
   903  }
   904  
   905  func TestGenParameter_Issue710(t *testing.T) {
   906  	log.SetOutput(ioutil.Discard)
   907  	defer func() {
   908  		log.SetOutput(os.Stdout)
   909  	}()
   910  
   911  	assert := assert.New(t)
   912  
   913  	gen, err := opBuilder("createTask", "../fixtures/codegen/todolist.allparams.yml")
   914  	if assert.NoError(err) {
   915  		op, err := gen.MakeOperation()
   916  		if assert.NoError(err) {
   917  			buf := bytes.NewBuffer(nil)
   918  			opts := opts()
   919  			err := templates.MustGet("clientParameter").Execute(buf, op)
   920  			if assert.NoError(err) {
   921  				ff, err := opts.LanguageOpts.FormatContent("create_task_parameter.go", buf.Bytes())
   922  				if assert.NoError(err) {
   923  					res := string(ff)
   924  					assertInCode(t, "(typeVar", res)
   925  				} else {
   926  					fmt.Println(buf.String())
   927  				}
   928  			}
   929  		}
   930  	}
   931  }
   932  
   933  func TestGenParameter_Issue776_LocalFileRef(t *testing.T) {
   934  	//spec.Debug = true
   935  	log.SetOutput(ioutil.Discard)
   936  	defer func() {
   937  		//spec.Debug = false
   938  		log.SetOutput(os.Stdout)
   939  	}()
   940  	b, err := opBuilderWithFlatten("GetItem", "../fixtures/bugs/776/param.yaml")
   941  	if assert.NoError(t, err) {
   942  		op, err := b.MakeOperation()
   943  		if assert.NoError(t, err) {
   944  			var buf bytes.Buffer
   945  			opts := opts()
   946  			if assert.NoError(t, templates.MustGet("serverParameter").Execute(&buf, op)) {
   947  				ff, err := opts.LanguageOpts.FormatContent("do_empty_responses.go", buf.Bytes())
   948  				if assert.NoError(t, err) {
   949  					assertInCode(t, "Body *models.Item", string(ff))
   950  					assertNotInCode(t, "type GetItemParamsBody struct", string(ff))
   951  				} else {
   952  					fmt.Println(buf.String())
   953  				}
   954  			}
   955  		}
   956  	}
   957  
   958  }
   959  
   960  func TestGenParameter_Issue1111(t *testing.T) {
   961  	assert := assert.New(t)
   962  
   963  	gen, err := opBuilder("start-es-cluster-instances", "../fixtures/bugs/1111/arrayParam.json")
   964  	if assert.NoError(err) {
   965  		op, err := gen.MakeOperation()
   966  		if assert.NoError(err) {
   967  			buf := bytes.NewBuffer(nil)
   968  			opts := opts()
   969  			err := templates.MustGet("clientParameter").Execute(buf, op)
   970  			if assert.NoError(err) {
   971  				ff, err := opts.LanguageOpts.FormatContent("post_clusters_elasticsearch_cluster_id_instances_instance_ids_start_parameters.go", buf.Bytes())
   972  				if assert.NoError(err) {
   973  					res := string(ff)
   974  					assertInCode(t, `r.SetPathParam("instance_ids", joinedInstanceIds[0])`, res)
   975  				} else {
   976  					fmt.Println(buf.String())
   977  				}
   978  			}
   979  		}
   980  	}
   981  }
   982  
   983  func TestGenParameter_Issue1462(t *testing.T) {
   984  	assert := assert.New(t)
   985  
   986  	gen, err := opBuilder("start-es-cluster-instances", "../fixtures/bugs/1462/arrayParam.json")
   987  	if assert.NoError(err) {
   988  		op, err := gen.MakeOperation()
   989  		if assert.NoError(err) {
   990  			buf := bytes.NewBuffer(nil)
   991  			opts := opts()
   992  			err := templates.MustGet("clientParameter").Execute(buf, op)
   993  			if assert.NoError(err) {
   994  				ff, err := opts.LanguageOpts.FormatContent("post_clusters_elasticsearch_cluster_id_instances_instance_ids_start_parameters.go", buf.Bytes())
   995  				if assert.NoError(err) {
   996  					res := string(ff)
   997  					assertInCode(t, `if len(joinedInstanceIds) > 0 {`, res)
   998  				} else {
   999  					fmt.Println(buf.String())
  1000  				}
  1001  			}
  1002  		}
  1003  	}
  1004  }
  1005  
  1006  func TestGenParameter_Issue1199(t *testing.T) {
  1007  	assert := assert.New(t)
  1008  	var assertion = `if o.Body != nil {
  1009  		if err := r.SetBodyParam(o.Body); err != nil {
  1010  			return err
  1011  		}
  1012  	}`
  1013  	gen, err := opBuilder("move-clusters", "../fixtures/bugs/1199/nonEmptyBody.json")
  1014  	if assert.NoError(err) {
  1015  		op, err := gen.MakeOperation()
  1016  		if assert.NoError(err) {
  1017  			buf := bytes.NewBuffer(nil)
  1018  			opts := opts()
  1019  			err := templates.MustGet("clientParameter").Execute(buf, op)
  1020  			if assert.NoError(err) {
  1021  				ff, err := opts.LanguageOpts.FormatContent("move_clusters_parameters.go", buf.Bytes())
  1022  				if assert.NoError(err) {
  1023  					res := string(ff)
  1024  					assertInCode(t, assertion, res)
  1025  				} else {
  1026  					fmt.Println(buf.String())
  1027  				}
  1028  			}
  1029  		}
  1030  	}
  1031  }
  1032  
  1033  func TestGenParameter_Issue1325(t *testing.T) {
  1034  	log.SetOutput(ioutil.Discard)
  1035  	defer func() {
  1036  		log.SetOutput(os.Stdout)
  1037  	}()
  1038  
  1039  	assert := assert.New(t)
  1040  
  1041  	gen, err := opBuilder("uploadFile", "../fixtures/bugs/1325/swagger.yaml")
  1042  	if assert.NoError(err) {
  1043  		op, err := gen.MakeOperation()
  1044  		if assert.NoError(err) {
  1045  			buf := bytes.NewBuffer(nil)
  1046  			opts := opts()
  1047  			err := templates.MustGet("clientParameter").Execute(buf, op)
  1048  			if assert.NoError(err) {
  1049  				ff, err := opts.LanguageOpts.FormatContent("create_task_parameter.go", buf.Bytes())
  1050  				if assert.NoError(err) {
  1051  					res := string(ff)
  1052  					assertInCode(t, "runtime.NamedReadCloser", res)
  1053  				} else {
  1054  					fmt.Println(buf.String())
  1055  				}
  1056  			}
  1057  		}
  1058  	}
  1059  }
  1060  
  1061  func TestGenParameter_ArrayQueryParameters(t *testing.T) {
  1062  	assert := assert.New(t)
  1063  
  1064  	gen, err := opBuilder("arrayQueryParams", "../fixtures/codegen/todolist.arrayquery.yml")
  1065  	if assert.NoError(err) {
  1066  		op, err := gen.MakeOperation()
  1067  		if assert.NoError(err) {
  1068  			buf := bytes.NewBuffer(nil)
  1069  			opts := opts()
  1070  			err := templates.MustGet("serverParameter").Execute(buf, op)
  1071  			if assert.NoError(err) {
  1072  				ff, err := opts.LanguageOpts.FormatContent("array_query_params.go", buf.Bytes())
  1073  				if assert.NoError(err) {
  1074  					res := string(ff)
  1075  					assertInCode(t, `siBoolIC := swag.SplitByFormat(qvSiBool, "ssv")`, res)
  1076  					assertInCode(t, `var siBoolIR []bool`, res)
  1077  					assertInCode(t, `for i, siBoolIV := range siBoolIC`, res)
  1078  					assertInCode(t, `siBoolI, err := swag.ConvertBool(siBoolIV)`, res)
  1079  					assertInCode(t, `siBoolIR = append(siBoolIR, siBoolI)`, res)
  1080  					assertInCode(t, `o.SiBool = siBoolIR`, res)
  1081  					assertInCode(t, `siBoolSize := int64(len(o.SiBool))`, res)
  1082  					assertInCode(t, `err := validate.MinItems("siBool", "query", siBoolSize, 5)`, res)
  1083  					assertInCode(t, `err := validate.MaxItems("siBool", "query", siBoolSize, 50)`, res)
  1084  
  1085  					assertInCode(t, `siFloatIC := rawData`, res)
  1086  					assertInCode(t, `var siFloatIR []float64`, res)
  1087  					assertInCode(t, `for i, siFloatIV := range siFloatIC`, res)
  1088  					assertInCode(t, `siFloatI, err := swag.ConvertFloat64(siFloatIV)`, res)
  1089  					assertInCode(t, `return errors.InvalidType(fmt.Sprintf("%s.%v", "siFloat", i), "query", "float64", siFloatI)`, res)
  1090  					assertInCode(t, `err := validate.Minimum(fmt.Sprintf("%s.%v", "siFloat", i), "query", float64(siFloatI), 3, true)`, res)
  1091  					assertInCode(t, `err := validate.Maximum(fmt.Sprintf("%s.%v", "siFloat", i), "query", float64(siFloatI), 100, true); err != nil`, res)
  1092  					assertInCode(t, `err := validate.MultipleOf(fmt.Sprintf("%s.%v", "siFloat", i), "query", float64(siFloatI), 1.5)`, res)
  1093  					assertInCode(t, `siFloatIR = append(siFloatIR, siFloatI)`, res)
  1094  					assertInCode(t, `o.SiFloat = siFloatIR`, res)
  1095  					assertInCode(t, `siFloatSize := int64(len(o.SiFloat))`, res)
  1096  					assertInCode(t, `err := validate.MinItems("siFloat", "query", siFloatSize, 5)`, res)
  1097  					assertInCode(t, `err := validate.MaxItems("siFloat", "query", siFloatSize, 50)`, res)
  1098  
  1099  					assertInCode(t, `siFloat32IC := swag.SplitByFormat(qvSiFloat32, "")`, res)
  1100  					assertInCode(t, `var siFloat32IR []float32`, res)
  1101  					assertInCode(t, `for i, siFloat32IV := range siFloat32IC`, res)
  1102  					assertInCode(t, `siFloat32I, err := swag.ConvertFloat32(siFloat32IV)`, res)
  1103  					assertInCode(t, `err := validate.Minimum(fmt.Sprintf("%s.%v", "siFloat32", i), "query", float64(siFloat32I), 3, true)`, res)
  1104  					assertInCode(t, `err := validate.Maximum(fmt.Sprintf("%s.%v", "siFloat32", i), "query", float64(siFloat32I), 100, true)`, res)
  1105  					assertInCode(t, `err := validate.MultipleOf(fmt.Sprintf("%s.%v", "siFloat32", i), "query", float64(siFloat32I), 1.5)`, res)
  1106  					assertInCode(t, `siFloat32IR = append(siFloat32IR, siFloat32I)`, res)
  1107  					assertInCode(t, `o.SiFloat32 = siFloat32IR`, res)
  1108  
  1109  					assertInCode(t, `siFloat64IC := swag.SplitByFormat(qvSiFloat64, "pipes")`, res)
  1110  					assertInCode(t, `var siFloat64IR []float64`, res)
  1111  					assertInCode(t, `for i, siFloat64IV := range siFloat64IC`, res)
  1112  					assertInCode(t, `siFloat64I, err := swag.ConvertFloat64(siFloat64IV)`, res)
  1113  					assertInCode(t, `err := validate.Minimum(fmt.Sprintf("%s.%v", "siFloat64", i), "query", float64(siFloat64I), 3, true)`, res)
  1114  					assertInCode(t, `err := validate.Maximum(fmt.Sprintf("%s.%v", "siFloat64", i), "query", float64(siFloat64I), 100, true)`, res)
  1115  					assertInCode(t, `err := validate.MultipleOf(fmt.Sprintf("%s.%v", "siFloat64", i), "query", float64(siFloat64I), 1.5)`, res)
  1116  					assertInCode(t, `siFloat64IR = append(siFloat64IR, siFloat64I)`, res)
  1117  					assertInCode(t, `o.SiFloat64 = siFloat64IR`, res)
  1118  					assertInCode(t, `siFloat64Size := int64(len(o.SiFloat64))`, res)
  1119  					assertInCode(t, `err := validate.MinItems("siFloat64", "query", siFloat64Size, 5)`, res)
  1120  					assertInCode(t, `err := validate.MaxItems("siFloat64", "query", siFloat64Size, 50)`, res)
  1121  
  1122  					assertInCode(t, `siIntIC := swag.SplitByFormat(qvSiInt, "pipes")`, res)
  1123  					assertInCode(t, `var siIntIR []int64`, res)
  1124  					assertInCode(t, `for i, siIntIV := range siIntIC`, res)
  1125  					assertInCode(t, `siIntI, err := swag.ConvertInt64(siIntIV)`, res)
  1126  					assertInCode(t, `err := validate.MinimumInt(fmt.Sprintf("%s.%v", "siInt", i), "query", int64(siIntI), 8, true)`, res)
  1127  					assertInCode(t, `err := validate.MaximumInt(fmt.Sprintf("%s.%v", "siInt", i), "query", int64(siIntI), 100, true)`, res)
  1128  					assertInCode(t, `err := validate.MultipleOf(fmt.Sprintf("%s.%v", "siInt", i), "query", float64(siIntI), 2)`, res)
  1129  					assertInCode(t, `siIntIR = append(siIntIR, siIntI)`, res)
  1130  					assertInCode(t, `o.SiInt = siIntIR`, res)
  1131  					assertInCode(t, `siIntSize := int64(len(o.SiInt))`, res)
  1132  					assertInCode(t, `err := validate.MinItems("siInt", "query", siIntSize, 5)`, res)
  1133  					assertInCode(t, `err := validate.MaxItems("siInt", "query", siIntSize, 50)`, res)
  1134  
  1135  					assertInCode(t, `siInt32IC := swag.SplitByFormat(qvSiInt32, "tsv")`, res)
  1136  					assertInCode(t, `var siInt32IR []int32`, res)
  1137  					assertInCode(t, `for i, siInt32IV := range siInt32IC`, res)
  1138  					assertInCode(t, `siInt32I, err := swag.ConvertInt32(siInt32IV)`, res)
  1139  					assertInCode(t, `err := validate.MinimumInt(fmt.Sprintf("%s.%v", "siInt32", i), "query", int64(siInt32I), 8, true)`, res)
  1140  					assertInCode(t, `err := validate.MaximumInt(fmt.Sprintf("%s.%v", "siInt32", i), "query", int64(siInt32I), 100, true)`, res)
  1141  					assertInCode(t, `err := validate.MultipleOf(fmt.Sprintf("%s.%v", "siInt32", i), "query", float64(siInt32I), 2)`, res)
  1142  					assertInCode(t, `siInt32IR = append(siInt32IR, siInt32I)`, res)
  1143  					assertInCode(t, `o.SiInt32 = siInt32IR`, res)
  1144  					assertInCode(t, `siFloat32Size := int64(len(o.SiFloat32))`, res)
  1145  					assertInCode(t, `err := validate.MinItems("siFloat32", "query", siFloat32Size, 5)`, res)
  1146  					assertInCode(t, `err := validate.MaxItems("siFloat32", "query", siFloat32Size, 50)`, res)
  1147  					assertInCode(t, `siInt32Size := int64(len(o.SiInt32))`, res)
  1148  					assertInCode(t, `err := validate.MinItems("siInt32", "query", siInt32Size, 5)`, res)
  1149  					assertInCode(t, `err := validate.MaxItems("siInt32", "query", siInt32Size, 50)`, res)
  1150  
  1151  					assertInCode(t, `siInt64IC := swag.SplitByFormat(qvSiInt64, "ssv")`, res)
  1152  					assertInCode(t, `var siInt64IR []int64`, res)
  1153  					assertInCode(t, `for i, siInt64IV := range siInt64IC`, res)
  1154  					assertInCode(t, `siInt64I, err := swag.ConvertInt64(siInt64IV)`, res)
  1155  					assertInCode(t, `err := validate.MinimumInt(fmt.Sprintf("%s.%v", "siInt64", i), "query", int64(siInt64I), 8, true)`, res)
  1156  					assertInCode(t, `err := validate.MaximumInt(fmt.Sprintf("%s.%v", "siInt64", i), "query", int64(siInt64I), 100, true)`, res)
  1157  					assertInCode(t, `err := validate.MultipleOf(fmt.Sprintf("%s.%v", "siInt64", i), "query", float64(siInt64I), 2)`, res)
  1158  					assertInCode(t, `siInt64IR = append(siInt64IR, siInt64I)`, res)
  1159  					assertInCode(t, `o.SiInt64 = siInt64IR`, res)
  1160  					assertInCode(t, `siInt64Size := int64(len(o.SiInt64))`, res)
  1161  					assertInCode(t, `err := validate.MinItems("siInt64", "query", siInt64Size, 5)`, res)
  1162  					assertInCode(t, `err := validate.MaxItems("siInt64", "query", siInt64Size, 50)`, res)
  1163  
  1164  					assertInCode(t, `siStringIC := swag.SplitByFormat(qvSiString, "csv")`, res)
  1165  					assertInCode(t, `var siStringIR []string`, res)
  1166  					assertInCode(t, `for i, siStringIV := range siStringIC`, res)
  1167  					assertInCode(t, `siStringI := siStringIV`, res)
  1168  					assertInCode(t, `err := validate.MinLength(fmt.Sprintf("%s.%v", "siString", i), "query", siStringI, 5)`, res)
  1169  					assertInCode(t, `err := validate.MaxLength(fmt.Sprintf("%s.%v", "siString", i), "query", siStringI, 50)`, res)
  1170  					assertInCode(t, `err := validate.Pattern(fmt.Sprintf("%s.%v", "siString", i), "query", siStringI, `+"`"+`[A-Z][\w-]+`+"`"+`)`, res)
  1171  					assertInCode(t, `siStringIR = append(siStringIR, siStringI)`, res)
  1172  					assertInCode(t, `o.SiString = siStringIR`, res)
  1173  					assertInCode(t, `siStringSize := int64(len(o.SiString))`, res)
  1174  					assertInCode(t, `err := validate.MinItems("siString", "query", siStringSize, 5)`, res)
  1175  					assertInCode(t, `err := validate.MaxItems("siString", "query", siStringSize, 50)`, res)
  1176  
  1177  					assertInCode(t, `siNestedIC := rawData`, res)
  1178  					assertInCode(t, `var siNestedIR [][][]string`, res)
  1179  					assertInCode(t, `for i, siNestedIV := range siNestedIC`, res)
  1180  					assertInCode(t, `siNestedIIC := swag.SplitByFormat(siNestedIV, "pipes")`, res)
  1181  					assertInCode(t, `var siNestedIIR [][]string`, res)
  1182  					assertInCode(t, `for ii, siNestedIIV := range siNestedIIC {`, res)
  1183  					assertInCode(t, `siNestedIIIC := swag.SplitByFormat(siNestedIIV, "csv")`, res)
  1184  					assertInCode(t, `var siNestedIIIR []string`, res)
  1185  					assertInCode(t, `for iii, siNestedIIIV := range siNestedIIIC`, res)
  1186  					assertInCode(t, `siNestedIII := siNestedIIIV`, res)
  1187  					assertInCode(t, `err := validate.MinLength(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "siNested", i), ii), iii), "query", siNestedIII, 5)`, res)
  1188  					assertInCode(t, `err := validate.MaxLength(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "siNested", i), ii), iii), "query", siNestedIII, 50)`, res)
  1189  					assertInCode(t, `err := validate.Pattern(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "siNested", i), ii), iii), "query", siNestedIII, `+"`"+`[A-Z][\w-]+`+"`"+`)`, res)
  1190  					assertInCode(t, `siNestedIIIR = append(siNestedIIIR, siNestedIII)`, res)
  1191  					assertInCode(t, `siNestedIIiSize := int64(len(siNestedIIIC))`, res) // NOTE(fredbi): fixed variable (nested arrays)
  1192  					assertInCode(t, `err := validate.MinItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "siNested", i), ii), "query", siNestedIIiSize, 3)`, res)
  1193  					assertInCode(t, `err := validate.MaxItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "siNested", i), ii), "query", siNestedIIiSize, 30)`, res)
  1194  					assertInCode(t, `siNestedIIR = append(siNestedIIR, siNestedIIIR)`, res) // NOTE(fredbi): fixed variable (nested arrays)
  1195  					assertInCode(t, `siNestedISize := int64(len(siNestedIIC))`, res)        //NOTE(fredbi): fixed variable (nested arrays)
  1196  					assertInCode(t, `err := validate.MinItems(fmt.Sprintf("%s.%v", "siNested", i), "query", siNestedISize, 2)`, res)
  1197  					assertInCode(t, `err := validate.MaxItems(fmt.Sprintf("%s.%v", "siNested", i), "query", siNestedISize, 20)`, res)
  1198  					assertInCode(t, `siNestedIR = append(siNestedIR, siNestedIIR)`, res) // NOTE(fredbi): fixed variable (nested arrays)
  1199  					assertInCode(t, `o.SiNested = siNestedIR`, res)
  1200  				} else {
  1201  					fmt.Println(buf.String())
  1202  				}
  1203  			}
  1204  		}
  1205  	}
  1206  }
  1207  
  1208  func assertParams(t *testing.T, fixtureConfig map[string]map[string][]string, fixture string, minimalFlatten bool, withExpand bool) {
  1209  	fixtureSpec := path.Base(fixture)
  1210  	tassert := assert.New(t)
  1211  	for fixtureIndex, fixtureContents := range fixtureConfig {
  1212  		var gen codeGenOpBuilder
  1213  		var err error
  1214  		if minimalFlatten && !withExpand {
  1215  			// proceed with minimal spec flattening
  1216  			gen, err = opBuilder(fixtureIndex, fixture)
  1217  		} else if !minimalFlatten {
  1218  			// proceed with full flattening
  1219  			gen, err = opBuilderWithFlatten(fixtureIndex, fixture)
  1220  		} else {
  1221  			// proceed with spec expansion
  1222  			gen, err = opBuilderWithExpand(fixtureIndex, fixture)
  1223  		}
  1224  		if tassert.NoError(err) {
  1225  			op, err := gen.MakeOperation()
  1226  			if tassert.NoError(err) {
  1227  				opts := opts()
  1228  				for fixtureTemplate, expectedCode := range fixtureContents {
  1229  					buf := bytes.NewBuffer(nil)
  1230  					err := templates.MustGet(fixtureTemplate).Execute(buf, op)
  1231  					if tassert.NoError(err, "Expected generation to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1232  						ff, err := opts.LanguageOpts.FormatContent("foo.go", buf.Bytes())
  1233  						if tassert.NoError(err, "Expected formatting to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1234  							res := string(ff)
  1235  							for line, codeLine := range expectedCode {
  1236  								if !assertInCode(t, strings.TrimSpace(codeLine), res) {
  1237  									t.Logf("Code expected did not match for fixture %s at line %d", fixtureSpec, line)
  1238  								}
  1239  							}
  1240  						} else {
  1241  							fmt.Println(buf.String())
  1242  						}
  1243  					}
  1244  				}
  1245  			}
  1246  		}
  1247  	}
  1248  }
  1249  
  1250  func TestGenParameter_Issue909(t *testing.T) {
  1251  	log.SetOutput(ioutil.Discard)
  1252  	defer func() {
  1253  		log.SetOutput(os.Stdout)
  1254  	}()
  1255  
  1256  	assert := assert.New(t)
  1257  	fixtureConfig := map[string]map[string][]string{
  1258  		"1": { // fixture index
  1259  			"serverParameter": { // executed template
  1260  				// expected code lines
  1261  				`strfmt "github.com/go-openapi/strfmt"`,
  1262  				`NotAnOption1 *strfmt.DateTime`,
  1263  				`NotAnOption2 *strfmt.UUID`,
  1264  				`NotAnOption3 *models.ContainerConfig`,
  1265  				`value, err := formats.Parse("date-time", raw)`,
  1266  				`o.NotAnOption1 = (value.(*strfmt.DateTime))`,
  1267  				`if err := o.validateNotAnOption1(formats); err != nil {`,
  1268  				`if err := validate.FormatOf("notAnOption1", "query", "date-time", o.NotAnOption1.String(), formats); err != nil {`,
  1269  				`value, err := formats.Parse("uuid", raw)`,
  1270  				`o.NotAnOption2 = (value.(*strfmt.UUID))`,
  1271  				`if err := o.validateNotAnOption2(formats); err != nil {`,
  1272  				`if err := validate.FormatOf("notAnOption2", "query", "uuid", o.NotAnOption2.String(), formats); err != nil {`,
  1273  			},
  1274  		},
  1275  		"2": {
  1276  			"serverParameter": {
  1277  				// expected code lines
  1278  				`"github.com/go-openapi/validate"`,
  1279  				`IsAnOption2 []strfmt.UUID`,
  1280  				`NotAnOption1 []strfmt.DateTime`,
  1281  				`NotAnOption3 *models.ContainerConfig`,
  1282  				`isAnOption2IC := swag.SplitByFormat(qvIsAnOption2, "csv")`,
  1283  				`var isAnOption2IR []strfmt.UUID`,
  1284  				`for i, isAnOption2IV := range isAnOption2IC {`,
  1285  				`value, err := formats.Parse("uuid", isAnOption2IV)`,
  1286  				`isAnOption2I := *(value.(*strfmt.UUID))`,
  1287  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", "isAnOption2", i), "query", "uuid", isAnOption2I.String(), formats); err != nil {`,
  1288  				`isAnOption2IR = append(isAnOption2IR, isAnOption2I)`,
  1289  				`o.IsAnOption2 = isAnOption2IR`,
  1290  				`return errors.Required("notAnOption1", "query")`,
  1291  				`notAnOption1IC := swag.SplitByFormat(qvNotAnOption1, "csv")`,
  1292  				`var notAnOption1IR []strfmt.DateTime`,
  1293  				`for i, notAnOption1IV := range notAnOption1IC {`,
  1294  				`value, err := formats.Parse("date-time", notAnOption1IV)`,
  1295  				`return errors.InvalidType(fmt.Sprintf("%s.%v", "notAnOption1", i), "query", "strfmt.DateTime", value)`,
  1296  				`notAnOption1I := *(value.(*strfmt.DateTime))`,
  1297  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", "notAnOption1", i), "query", "date-time", notAnOption1I.String(), formats); err != nil {`,
  1298  				`notAnOption1IR = append(notAnOption1IR, notAnOption1I)`,
  1299  				`o.NotAnOption1 = notAnOption1IR`,
  1300  			},
  1301  		},
  1302  		"3": {
  1303  			"serverParameter": {
  1304  				// expected code lines
  1305  				`"github.com/go-openapi/validate"`,
  1306  				`strfmt "github.com/go-openapi/strfmt"`,
  1307  				`IsAnOption2 [][]strfmt.UUID`,
  1308  				`IsAnOption4 [][][]strfmt.UUID`,
  1309  				`IsAnOptionalHeader [][]strfmt.UUID`,
  1310  				`NotAnOption1 [][]strfmt.DateTime`,
  1311  				`NotAnOption3 *models.ContainerConfig`,
  1312  				`isAnOption2IC := swag.SplitByFormat(qvIsAnOption2, "pipes")`,
  1313  				`var isAnOption2IR [][]strfmt.UUID`,
  1314  				`for i, isAnOption2IV := range isAnOption2IC {`,
  1315  				`isAnOption2IIC := swag.SplitByFormat(isAnOption2IV, "")`,
  1316  				`if len(isAnOption2IIC) > 0 {`,
  1317  				`var isAnOption2IIR []strfmt.UUID`,
  1318  				`for ii, isAnOption2IIV := range isAnOption2IIC {`,
  1319  				`value, err := formats.Parse("uuid", isAnOption2IIV)`,
  1320  				`isAnOption2II := *(value.(*strfmt.UUID))`,
  1321  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption2", i), ii), "query", "uuid", isAnOption2II.String(), formats); err != nil {`,
  1322  				`isAnOption2IIR = append(isAnOption2IIR, isAnOption2II)`,
  1323  				`isAnOption2IR = append(isAnOption2IR, isAnOption2IIR)`,
  1324  				`o.IsAnOption2 = isAnOption2IR`,
  1325  				`isAnOption4IC := swag.SplitByFormat(qvIsAnOption4, "csv")`,
  1326  				`var isAnOption4IR [][][]strfmt.UUID`,
  1327  				`for i, isAnOption4IV := range isAnOption4IC {`,
  1328  				`isAnOption4IIC := swag.SplitByFormat(isAnOption4IV, "")`,
  1329  				`if len(isAnOption4IIC) > 0 {`,
  1330  				`var isAnOption4IIR [][]strfmt.UUID`,
  1331  				`for ii, isAnOption4IIV := range isAnOption4IIC {`,
  1332  				`isAnOption4IIIC := swag.SplitByFormat(isAnOption4IIV, "pipes")`,
  1333  				`if len(isAnOption4IIIC) > 0 {`,
  1334  				`var isAnOption4IIIR []strfmt.UUID`,
  1335  				`for iii, isAnOption4IIIV := range isAnOption4IIIC {`,
  1336  				`value, err := formats.Parse("uuid", isAnOption4IIIV)`,
  1337  				`isAnOption4III := *(value.(*strfmt.UUID))`,
  1338  				`if err := validate.Enum(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), iii), "query", isAnOption4III.String(), []interface{}{"a", "b", "c"}); err != nil {`,
  1339  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), iii), "query", "uuid", isAnOption4III.String(), formats); err != nil {`,
  1340  				`isAnOption4IIIR = append(isAnOption4IIIR, isAnOption4III)`,
  1341  				`isAnOption4IIR = append(isAnOption4IIR, isAnOption4IIIR)`,
  1342  				`isAnOption4IIiSize := int64(len(isAnOption4IIIC))`,
  1343  				`if err := validate.MinItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), "query", isAnOption4IIiSize, 3); err != nil {`,
  1344  				`if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), "query", isAnOption4IIIC); err != nil {`,
  1345  				`isAnOption4IR = append(isAnOption4IR, isAnOption4IIR)`,
  1346  				`if err := validate.UniqueItems(fmt.Sprintf("%s.%v", "isAnOption4", i), "query", isAnOption4IIC); err != nil {`,
  1347  				`o.IsAnOption4 = isAnOption4IR`,
  1348  				`if err := o.validateIsAnOption4(formats); err != nil {`,
  1349  				`if err := validate.MaxItems("isAnOption4", "query", isAnOption4Size, 4); err != nil {`,
  1350  				`isAnOptionalHeaderIC := swag.SplitByFormat(qvIsAnOptionalHeader, "pipes")`,
  1351  				`var isAnOptionalHeaderIR [][]strfmt.UUID`,
  1352  				`for i, isAnOptionalHeaderIV := range isAnOptionalHeaderIC {`,
  1353  				`isAnOptionalHeaderIIC := swag.SplitByFormat(isAnOptionalHeaderIV, "")`,
  1354  				`if len(isAnOptionalHeaderIIC) > 0 {`,
  1355  				`var isAnOptionalHeaderIIR []strfmt.UUID`,
  1356  				`for ii, isAnOptionalHeaderIIV := range isAnOptionalHeaderIIC {`,
  1357  				`value, err := formats.Parse("uuid", isAnOptionalHeaderIIV)`,
  1358  				`isAnOptionalHeaderII := *(value.(*strfmt.UUID))`,
  1359  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOptionalHeader", i), ii), "header", "uuid", isAnOptionalHeaderII.String(), formats); err != nil {`,
  1360  				`isAnOptionalHeaderIIR = append(isAnOptionalHeaderIIR, isAnOptionalHeaderII)`,
  1361  				`isAnOptionalHeaderIR = append(isAnOptionalHeaderIR, isAnOptionalHeaderIIR)`,
  1362  				`o.IsAnOptionalHeader = isAnOptionalHeaderIR`,
  1363  				`if err := o.validateIsAnOptionalHeader(formats); err != nil {`,
  1364  				`if err := validate.UniqueItems("isAnOptionalHeader", "header", o.IsAnOptionalHeader); err != nil {`,
  1365  				`notAnOption1IC := swag.SplitByFormat(qvNotAnOption1, "csv")`,
  1366  				`var notAnOption1IR [][]strfmt.DateTime`,
  1367  				`for i, notAnOption1IV := range notAnOption1IC {`,
  1368  				`notAnOption1IIC := swag.SplitByFormat(notAnOption1IV, "pipes")`,
  1369  				`if len(notAnOption1IIC) > 0 {`,
  1370  				`var notAnOption1IIR []strfmt.DateTime`,
  1371  				`for ii, notAnOption1IIV := range notAnOption1IIC {`,
  1372  				`value, err := formats.Parse("date-time", notAnOption1IIV)`,
  1373  				`notAnOption1II := *(value.(*strfmt.DateTime))`,
  1374  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "notAnOption1", i), ii), "query", "date-time", notAnOption1II.String(), formats); err != nil {`,
  1375  				`notAnOption1IIR = append(notAnOption1IIR, notAnOption1II)`,
  1376  				`notAnOption1IR = append(notAnOption1IR, notAnOption1IIR)`,
  1377  				`o.NotAnOption1 = notAnOption1IR`,
  1378  			},
  1379  		},
  1380  		"4": {
  1381  			"serverParameter": {
  1382  				// expected code lines
  1383  				`"github.com/go-openapi/validate"`,
  1384  				`strfmt "github.com/go-openapi/strfmt"`,
  1385  				`IsAnOption2 [][]strfmt.UUID`,
  1386  				`IsAnOption4 [][][]strfmt.UUID`,
  1387  				`NotAnOption1 [][]strfmt.DateTime`,
  1388  				`NotAnOption3 *models.ContainerConfig`,
  1389  				`isAnOption2IC := swag.SplitByFormat(qvIsAnOption2, "")`,
  1390  				`var isAnOption2IR [][]strfmt.UUID`,
  1391  				`for i, isAnOption2IV := range isAnOption2IC {`,
  1392  				`isAnOption2IIC := swag.SplitByFormat(isAnOption2IV, "pipes")`,
  1393  				`if len(isAnOption2IIC) > 0 {`,
  1394  				`var isAnOption2IIR []strfmt.UUID`,
  1395  				`for ii, isAnOption2IIV := range isAnOption2IIC {`,
  1396  				`value, err := formats.Parse("uuid", isAnOption2IIV)`,
  1397  				`isAnOption2II := *(value.(*strfmt.UUID))`,
  1398  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption2", i), ii), "query", "uuid", isAnOption2II.String(), formats); err != nil {`,
  1399  				`isAnOption2IIR = append(isAnOption2IIR, isAnOption2II)`,
  1400  				`isAnOption2IR = append(isAnOption2IR, isAnOption2IIR)`,
  1401  				`o.IsAnOption2 = isAnOption2IR`,
  1402  				`isAnOption4IC := swag.SplitByFormat(qvIsAnOption4, "")`,
  1403  				`var isAnOption4IR [][][]strfmt.UUID`,
  1404  				`for i, isAnOption4IV := range isAnOption4IC {`,
  1405  				`isAnOption4IIC := swag.SplitByFormat(isAnOption4IV, "pipes")`,
  1406  				`if len(isAnOption4IIC) > 0 {`,
  1407  				`var isAnOption4IIR [][]strfmt.UUID`,
  1408  				`for ii, isAnOption4IIV := range isAnOption4IIC {`,
  1409  				`isAnOption4IIIC := swag.SplitByFormat(isAnOption4IIV, "tsv")`,
  1410  				`if len(isAnOption4IIIC) > 0 {`,
  1411  				`var isAnOption4IIIR []strfmt.UUID`,
  1412  				`for iii, isAnOption4IIIV := range isAnOption4IIIC {`,
  1413  				`value, err := formats.Parse("uuid", isAnOption4IIIV)`,
  1414  				`isAnOption4III := *(value.(*strfmt.UUID))`,
  1415  				`if err := validate.Enum(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), iii), "query", isAnOption4III.String(), []interface{}{"a", "b", "c"}); err != nil {`,
  1416  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), iii), "query", "uuid", isAnOption4III.String(), formats); err != nil {`,
  1417  				`isAnOption4IIIR = append(isAnOption4IIIR, isAnOption4III)`,
  1418  				`isAnOption4IIR = append(isAnOption4IIR, isAnOption4IIIR)`,
  1419  				`isAnOption4IIiSize := int64(len(isAnOption4IIIC))`,
  1420  				`if err := validate.MinItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), "query", isAnOption4IIiSize, 3); err != nil {`,
  1421  				`if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "isAnOption4", i), ii), "query", isAnOption4IIIC); err != nil {`,
  1422  				`isAnOption4IR = append(isAnOption4IR, isAnOption4IIR)`,
  1423  				`if err := validate.UniqueItems(fmt.Sprintf("%s.%v", "isAnOption4", i), "query", isAnOption4IIC); err != nil {`,
  1424  				`o.IsAnOption4 = isAnOption4IR`,
  1425  				`if err := o.validateIsAnOption4(formats); err != nil {`,
  1426  				`isAnOption4Size := int64(len(o.IsAnOption4))`,
  1427  				`if err := validate.MaxItems("isAnOption4", "query", isAnOption4Size, 4); err != nil {`,
  1428  				`return errors.Required("notAnOption1", "query")`,
  1429  				`notAnOption1IC := swag.SplitByFormat(qvNotAnOption1, "")`,
  1430  				`var notAnOption1IR [][]strfmt.DateTime`,
  1431  				`for i, notAnOption1IV := range notAnOption1IC {`,
  1432  				`notAnOption1IIC := swag.SplitByFormat(notAnOption1IV, "")`,
  1433  				`if len(notAnOption1IIC) > 0 {`,
  1434  				`var notAnOption1IIR []strfmt.DateTime`,
  1435  				`for ii, notAnOption1IIV := range notAnOption1IIC {`,
  1436  				`value, err := formats.Parse("date-time", notAnOption1IIV)`,
  1437  				`notAnOption1II := *(value.(*strfmt.DateTime))`,
  1438  				`if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "notAnOption1", i), ii), "query", "date-time", notAnOption1II.String(), formats); err != nil {`,
  1439  				`notAnOption1IIR = append(notAnOption1IIR, notAnOption1II)`,
  1440  				`notAnOption1IR = append(notAnOption1IR, notAnOption1IIR)`,
  1441  				`o.NotAnOption1 = notAnOption1IR`,
  1442  			},
  1443  		},
  1444  		"5": {
  1445  			"serverResponses": {
  1446  				// expected code lines
  1447  				`"github.com/go-openapi/strfmt"`,
  1448  				"XIsAnOptionalHeader0 strfmt.DateTime `json:\"x-isAnOptionalHeader0\"`",
  1449  				"XIsAnOptionalHeader1 []strfmt.DateTime `json:\"x-isAnOptionalHeader1\"`",
  1450  				"XIsAnOptionalHeader2 [][]int32 `json:\"x-isAnOptionalHeader2\"`",
  1451  				"XIsAnOptionalHeader3 [][][]strfmt.UUID `json:\"x-isAnOptionalHeader3\"`",
  1452  				`xIsAnOptionalHeader0 := o.XIsAnOptionalHeader0.String()`,
  1453  				`rw.Header().Set("x-isAnOptionalHeader0", xIsAnOptionalHeader0)`,
  1454  				`var xIsAnOptionalHeader1IR []string`,
  1455  				`for _, xIsAnOptionalHeader1I := range o.XIsAnOptionalHeader1 {`,
  1456  				`xIsAnOptionalHeader1IS := xIsAnOptionalHeader1I.String()`,
  1457  				`if xIsAnOptionalHeader1IS != "" {`,
  1458  				`xIsAnOptionalHeader1IR = append(xIsAnOptionalHeader1IR, xIsAnOptionalHeader1IS)`,
  1459  				`xIsAnOptionalHeader1 := swag.JoinByFormat(xIsAnOptionalHeader1IR, "tsv")`,
  1460  				`hv := xIsAnOptionalHeader1[0]`,
  1461  				`rw.Header().Set("x-isAnOptionalHeader1", hv)`,
  1462  				`var xIsAnOptionalHeader2IR []string`,
  1463  				`for _, xIsAnOptionalHeader2I := range o.XIsAnOptionalHeader2 {`,
  1464  				`var xIsAnOptionalHeader2IIR []string`,
  1465  				`for _, xIsAnOptionalHeader2II := range xIsAnOptionalHeader2I {`,
  1466  				`xIsAnOptionalHeader2IIS := swag.FormatInt32(xIsAnOptionalHeader2II)`,
  1467  				`if xIsAnOptionalHeader2IIS != "" {`,
  1468  				`xIsAnOptionalHeader2IIR = append(xIsAnOptionalHeader2IIR, xIsAnOptionalHeader2IIS)`,
  1469  				`xIsAnOptionalHeader2IS := swag.JoinByFormat(xIsAnOptionalHeader2IIR, "pipes")`,
  1470  				`xIsAnOptionalHeader2ISs := xIsAnOptionalHeader2IS[0]`,
  1471  				`if xIsAnOptionalHeader2ISs != "" {`,
  1472  				`xIsAnOptionalHeader2IR = append(xIsAnOptionalHeader2IR, xIsAnOptionalHeader2ISs)`,
  1473  				`xIsAnOptionalHeader2 := swag.JoinByFormat(xIsAnOptionalHeader2IR, "")`,
  1474  				`hv := xIsAnOptionalHeader2[0]`,
  1475  				`rw.Header().Set("x-isAnOptionalHeader2", hv)`,
  1476  				`var xIsAnOptionalHeader3IR []string`,
  1477  				`for _, xIsAnOptionalHeader3I := range o.XIsAnOptionalHeader3 {`,
  1478  				`var xIsAnOptionalHeader3IIR []string`,
  1479  				`for _, xIsAnOptionalHeader3II := range xIsAnOptionalHeader3I {`,
  1480  				`var xIsAnOptionalHeader3IIIR []string`,
  1481  				`for _, xIsAnOptionalHeader3III := range xIsAnOptionalHeader3II {`,
  1482  				`xIsAnOptionalHeader3IIIS := xIsAnOptionalHeader3III.String()`,
  1483  				`if xIsAnOptionalHeader3IIIS != "" {`,
  1484  				`xIsAnOptionalHeader3IIIR = append(xIsAnOptionalHeader3IIIR, xIsAnOptionalHeader3IIIS)`,
  1485  				`xIsAnOptionalHeader3IIS := swag.JoinByFormat(xIsAnOptionalHeader3IIIR, "")`,
  1486  				`xIsAnOptionalHeader3IISs := xIsAnOptionalHeader3IIS[0]`,
  1487  				`if xIsAnOptionalHeader3IISs != "" {`,
  1488  				`xIsAnOptionalHeader3IIR = append(xIsAnOptionalHeader3IIR, xIsAnOptionalHeader3IISs)`,
  1489  				`xIsAnOptionalHeader3IS := swag.JoinByFormat(xIsAnOptionalHeader3IIR, "pipes")`,
  1490  				`xIsAnOptionalHeader3ISs := xIsAnOptionalHeader3IS[0]`,
  1491  				`if xIsAnOptionalHeader3ISs != "" {`,
  1492  				`xIsAnOptionalHeader3IR = append(xIsAnOptionalHeader3IR, xIsAnOptionalHeader3ISs)`,
  1493  				`xIsAnOptionalHeader3 := swag.JoinByFormat(xIsAnOptionalHeader3IR, "")`,
  1494  				`hv := xIsAnOptionalHeader3[0]`,
  1495  				`rw.Header().Set("x-isAnOptionalHeader3", hv)`,
  1496  			},
  1497  		},
  1498  	}
  1499  
  1500  	for fixtureIndex, fixtureContents := range fixtureConfig {
  1501  		fixtureSpec := strings.Join([]string{"fixture-909-", fixtureIndex, ".yaml"}, "")
  1502  		gen, err := opBuilder("getOptional", filepath.Join("..", "fixtures", "bugs", "909", fixtureSpec))
  1503  		if assert.NoError(err) {
  1504  			op, err := gen.MakeOperation()
  1505  			if assert.NoError(err) {
  1506  				opts := opts()
  1507  				for fixtureTemplate, expectedCode := range fixtureContents {
  1508  					buf := bytes.NewBuffer(nil)
  1509  					err := templates.MustGet(fixtureTemplate).Execute(buf, op)
  1510  					if assert.NoError(err, "Expected generation to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1511  						ff, err := opts.LanguageOpts.FormatContent("foo.go", buf.Bytes())
  1512  						if assert.NoError(err, "Expected formatting to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1513  							res := string(ff)
  1514  							for line, codeLine := range expectedCode {
  1515  								if !assertInCode(t, strings.TrimSpace(codeLine), res) {
  1516  									t.Logf("Code expected did not match for fixture %s at line %d", fixtureSpec, line)
  1517  								}
  1518  							}
  1519  						} else {
  1520  							fmt.Println(buf.String())
  1521  						}
  1522  					}
  1523  				}
  1524  			}
  1525  		}
  1526  	}
  1527  }
  1528  
  1529  // verifies that validation method is called on body param with $ref
  1530  func TestGenParameter_Issue1237(t *testing.T) {
  1531  	log.SetOutput(ioutil.Discard)
  1532  	defer func() {
  1533  		log.SetOutput(os.Stdout)
  1534  	}()
  1535  
  1536  	assert := assert.New(t)
  1537  	fixtureConfig := map[string]map[string][]string{
  1538  		"1": { // fixture index
  1539  			"serverParameter": { // executed template
  1540  				// expected code lines
  1541  				`var body models.Sg`,
  1542  				`if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1543  				`if err == io.EOF {`,
  1544  				`res = append(res, errors.Required("body", "body"))`,
  1545  				`} else {`,
  1546  				`res = append(res, errors.NewParseError("body", "body", "", err))`,
  1547  				`if err := body.Validate(route.Formats); err != nil {`,
  1548  			},
  1549  		},
  1550  	}
  1551  	for _, fixtureContents := range fixtureConfig {
  1552  		fixtureSpec := strings.Join([]string{"fixture-1237", ".json"}, "")
  1553  		gen, err := opBuilder("add sg", filepath.Join("..", "fixtures", "bugs", "1237", fixtureSpec))
  1554  		if assert.NoError(err) {
  1555  			op, err := gen.MakeOperation()
  1556  			if assert.NoError(err) {
  1557  				opts := opts()
  1558  				for fixtureTemplate, expectedCode := range fixtureContents {
  1559  					buf := bytes.NewBuffer(nil)
  1560  					err := templates.MustGet(fixtureTemplate).Execute(buf, op)
  1561  					if assert.NoError(err, "Expected generation to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1562  						ff, err := opts.LanguageOpts.FormatContent("foo.go", buf.Bytes())
  1563  						if assert.NoError(err, "Expected formatting to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1564  							res := string(ff)
  1565  							for line, codeLine := range expectedCode {
  1566  								if !assertInCode(t, strings.TrimSpace(codeLine), res) {
  1567  									t.Logf("Code expected did not match for fixture %s at line %d", fixtureSpec, line)
  1568  								}
  1569  							}
  1570  						} else {
  1571  							fmt.Println(buf.String())
  1572  						}
  1573  					}
  1574  				}
  1575  			}
  1576  		}
  1577  	}
  1578  }
  1579  
  1580  func TestGenParameter_Issue1392(t *testing.T) {
  1581  	log.SetOutput(ioutil.Discard)
  1582  	defer func() {
  1583  		log.SetOutput(os.Stdout)
  1584  	}()
  1585  
  1586  	assert := assert.New(t)
  1587  	fixtureConfig := map[string]map[string][]string{
  1588  		"1": { // fixture index
  1589  			"serverParameter": { // executed template
  1590  				`func (o *PatchSomeResourceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1591  				`	var res []error`,
  1592  				`	o.HTTPRequest = r`,
  1593  				`	if runtime.HasBody(r) {`,
  1594  				`		defer r.Body.Close()`,
  1595  				`		var body models.BulkUpdateState`,
  1596  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1597  				`			res = append(res, errors.NewParseError("massUpdate", "body", "", err))`,
  1598  				`		} else {`,
  1599  				`			if err := body.Validate(route.Formats); err != nil {`,
  1600  				`				res = append(res, err)`,
  1601  				`			if len(res) == 0 {`,
  1602  				`				o.MassUpdate = body`,
  1603  				`	if len(res) > 0 {`,
  1604  				`		return errors.CompositeValidationError(res...)`,
  1605  			},
  1606  		},
  1607  		"2": { // fixture index
  1608  			"serverParameter": { // executed template
  1609  				// expected code lines
  1610  				`func (o *PostBodybuilder20Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1611  				`	var res []error`,
  1612  				`	o.HTTPRequest = r`,
  1613  				`	if runtime.HasBody(r) {`,
  1614  				`		defer r.Body.Close()`,
  1615  				`		var body []strfmt.URI`,
  1616  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1617  				`			res = append(res, errors.NewParseError("myObject", "body", "", err))`,
  1618  				`		} else {`,
  1619  				`			// validate inline body array`,
  1620  				`			o.MyObject = body`,
  1621  				`			if err := o.validateMyObjectBody(route.Formats); err != nil {`,
  1622  				`				res = append(res, err)`,
  1623  				`	if len(res) > 0 {`,
  1624  				`		return errors.CompositeValidationError(res...)`,
  1625  				`func (o *PostBodybuilder20Params) validateMyObjectBody(formats strfmt.Registry) error {`,
  1626  				`	// uniqueItems: true`,
  1627  				`	if err := validate.UniqueItems("myObject", "body", o.MyObject); err != nil {`,
  1628  				`	myObjectIC := o.MyObject`,
  1629  				`	var myObjectIR []strfmt.URI`,
  1630  				`	for i, myObjectIV := range myObjectIC {`,
  1631  				`		myObjectI := myObjectIV`,
  1632  				`		if err := validate.FormatOf(fmt.Sprintf("%s.%v", "myObject", i), "body", "uri", myObjectI.String(), formats); err != nil {`,
  1633  				`		myObjectIR = append(myObjectIR, myObjectI)`,
  1634  				`	o.MyObject = myObjectIR`,
  1635  			},
  1636  		},
  1637  		"3": { // fixture index
  1638  			"serverParameter": { // executed template
  1639  				// expected code lines
  1640  				`func (o *PostBodybuilder26Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1641  				`	var res []error`,
  1642  				`	o.HTTPRequest = r`,
  1643  				`	qs := runtime.Values(r.URL.Query())`,
  1644  				`	if runtime.HasBody(r) {`,
  1645  				`		defer r.Body.Close()`,
  1646  				`		var body strfmt.Date`,
  1647  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1648  				`			res = append(res, errors.NewParseError("myObject", "body", "", err))`,
  1649  				`		} else {`,
  1650  				`			// validate inline body`,
  1651  				`			o.MyObject = body`,
  1652  				`			if err := o.validateMyObjectBody(route.Formats); err != nil {`,
  1653  				`				res = append(res, err)`,
  1654  				`	qMyquery, qhkMyquery, _ := qs.GetOK("myquery")`,
  1655  				`	if err := o.bindMyquery(qMyquery, qhkMyquery, route.Formats); err != nil {`,
  1656  				`		res = append(res, err)`,
  1657  				`	if len(res) > 0 {`,
  1658  				`		return errors.CompositeValidationError(res...)`,
  1659  				`	return nil`,
  1660  				`func (o *PostBodybuilder26Params) validateMyObjectBody(formats strfmt.Registry) error {`,
  1661  				`	if err := validate.Enum("myObject", "body", o.MyObject.String(), []interface{}{"1992-01-01", "2012-01-01"}); err != nil {`,
  1662  				`	if err := validate.FormatOf("myObject", "body", "date", o.MyObject.String(), formats); err != nil {`,
  1663  			},
  1664  		},
  1665  		"4": { // fixture index
  1666  			"serverParameter": { // executed template
  1667  				// expected code lines
  1668  				`func (o *PostBodybuilder27Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1669  				`	var res []error`,
  1670  				`	o.HTTPRequest = r`,
  1671  				`	if runtime.HasBody(r) {`,
  1672  				`		defer r.Body.Close()`,
  1673  				`		var body [][]strfmt.Date`,
  1674  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1675  				`			res = append(res, errors.NewParseError("myObject", "body", "", err))`,
  1676  				`		} else {`,
  1677  				`			o.MyObject = body`,
  1678  				`			if err := o.validateMyObjectBody(route.Formats); err != nil {`,
  1679  				`				res = append(res, err)`,
  1680  				`	if len(res) > 0 {`,
  1681  				`		return errors.CompositeValidationError(res...)`,
  1682  				`func (o *PostBodybuilder27Params) validateMyObjectBody(formats strfmt.Registry) error {`,
  1683  				`	if err := validate.Enum("myObject", "body", o.MyObject, []interface{}{[]interface{}{[]interface{}{"1992-01-01", "2012-01-01"}}}); err != nil {`,
  1684  				`		return err`,
  1685  				`	myObjectIC := o.MyObject`,
  1686  				`	var myObjectIR [][]strfmt.Date`,
  1687  				`	for i, myObjectIV := range myObjectIC {`,
  1688  				`		myObjectIIC := myObjectIV`,
  1689  				`		if len(myObjectIIC) > 0 {`,
  1690  				`			var myObjectIIR []strfmt.Date`,
  1691  				`			for ii, myObjectIIV := range myObjectIIC {`,
  1692  				`				myObjectII := myObjectIIV`,
  1693  				`				if err := validate.Enum(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "myObject", i), ii), "", myObjectII.String(), []interface{}{"1992-01-01", "2012-01-01"}); err != nil {`,
  1694  				`					return err`,
  1695  				`				if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "myObject", i), ii), "", "date", myObjectII.String(), formats); err != nil {`,
  1696  				`					return err`,
  1697  				`				myObjectIIR = append(myObjectIIR, myObjectII)`,
  1698  				`			myObjectIR = append(myObjectIR, myObjectIIR)`,
  1699  				// fixed missing enum validation
  1700  				`		if err := validate.Enum(fmt.Sprintf("%s.%v", "myObject", i), "body", myObjectIIC, []interface{}{[]interface{}{"1992-01-01", "2012-01-01"}}); err != nil {`,
  1701  				`	o.MyObject = myObjectIR`,
  1702  			},
  1703  		},
  1704  		"5": { // fixture index
  1705  			"serverParameter": { // executed template
  1706  				`func (o *Bodybuilder23Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1707  				`	var res []error`,
  1708  				`	o.HTTPRequest = r`,
  1709  				`	if runtime.HasBody(r) {`,
  1710  				`		defer r.Body.Close()`,
  1711  				`		var body []models.ASimpleArray`,
  1712  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1713  				`			res = append(res, errors.NewParseError("myObject", "body", "", err))`,
  1714  				`		} else {`,
  1715  				`			o.MyObject = body`,
  1716  				`			myObjectSize := int64(len(o.MyObject))`,
  1717  				`			if err := validate.MinItems("myObject", "body", myObjectSize, 15); err != nil {`,
  1718  				`				return err`,
  1719  				// changed index
  1720  				`			for i := range body {`,
  1721  				`				if err := body[i].Validate(route.Formats); err != nil {`,
  1722  				`					res = append(res, err)`,
  1723  				`					break`,
  1724  				// removed redundant assignment
  1725  				//`			if len(res) == 0 {`,
  1726  				//`				o.MyObject = body`,
  1727  				`	if len(res) > 0 {`,
  1728  				`		return errors.CompositeValidationError(res...)`,
  1729  			},
  1730  		},
  1731  	}
  1732  
  1733  	for fixtureIndex, fixtureContents := range fixtureConfig {
  1734  		fixtureSpec := strings.Join([]string{"fixture-1392-", fixtureIndex, ".yaml"}, "")
  1735  		// pick selected operation id in fixture
  1736  		operationToTest := ""
  1737  		switch fixtureIndex {
  1738  		case "1":
  1739  			operationToTest = "PatchSomeResource"
  1740  		case "2":
  1741  			operationToTest = "PostBodybuilder20"
  1742  		case "3":
  1743  			operationToTest = "PostBodybuilder26"
  1744  		case "4":
  1745  			operationToTest = "PostBodybuilder27"
  1746  		case "5":
  1747  			operationToTest = "Bodybuilder23"
  1748  		}
  1749  		gen, err := opBuilder(operationToTest, filepath.Join("..", "fixtures", "bugs", "1392", fixtureSpec))
  1750  		if assert.NoError(err) {
  1751  			op, err := gen.MakeOperation()
  1752  			if assert.NoError(err) {
  1753  				opts := opts()
  1754  				for fixtureTemplate, expectedCode := range fixtureContents {
  1755  					buf := bytes.NewBuffer(nil)
  1756  					err := templates.MustGet(fixtureTemplate).Execute(buf, op)
  1757  					if assert.NoError(err, "Expected generation to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1758  						ff, err := opts.LanguageOpts.FormatContent("foo.go", buf.Bytes())
  1759  						if assert.NoError(err, "Expected formatting to go well on %s with template %s", fixtureSpec, fixtureTemplate) {
  1760  							res := string(ff)
  1761  							for line, codeLine := range expectedCode {
  1762  								if !assertInCode(t, strings.TrimSpace(codeLine), res) {
  1763  									t.Logf("Code expected did not match for fixture %s at line %d", fixtureSpec, line)
  1764  								}
  1765  							}
  1766  						} else {
  1767  							fmt.Println(buf.String())
  1768  						}
  1769  					}
  1770  				}
  1771  			}
  1772  		}
  1773  	}
  1774  }
  1775  
  1776  func TestGenParameter_Issue1513(t *testing.T) {
  1777  	log.SetOutput(ioutil.Discard)
  1778  	defer log.SetOutput(os.Stdout)
  1779  
  1780  	assert := assert.New(t)
  1781  	var assertion = `r.SetBodyParam(o.Something)`
  1782  	gen, err := opBuilderWithFlatten("put-enum", "../fixtures/bugs/1513/enums.yaml")
  1783  	if assert.NoError(err) {
  1784  		op, err := gen.MakeOperation()
  1785  		if assert.NoError(err) {
  1786  			buf := bytes.NewBuffer(nil)
  1787  			opts := opts()
  1788  			err := templates.MustGet("clientParameter").Execute(buf, op)
  1789  			if assert.NoError(err) {
  1790  				ff, err := opts.LanguageOpts.FormatContent("move_clusters_parameters.go", buf.Bytes())
  1791  				if assert.NoError(err) {
  1792  					res := string(ff)
  1793  					assertInCode(t, assertion, res)
  1794  				} else {
  1795  					fmt.Println(buf.String())
  1796  				}
  1797  			}
  1798  		}
  1799  	}
  1800  }
  1801  
  1802  // Body param validation on empty objects
  1803  func TestGenParameter_Issue1536(t *testing.T) {
  1804  	log.SetOutput(ioutil.Discard)
  1805  	defer func() {
  1806  		log.SetOutput(os.Stdout)
  1807  	}()
  1808  
  1809  	// testing fixture-1536.yaml with flatten
  1810  	// param body with array of empty objects
  1811  
  1812  	fixtureConfig := map[string]map[string][]string{
  1813  
  1814  		// load expectations for parameters in operation get_interface_parameters.go
  1815  		"getInterface": { // fixture index
  1816  			"serverParameter": { // executed template
  1817  				// expected code lines
  1818  				`func NewGetInterfaceParams() GetInterfaceParams {`,
  1819  				`	return GetInterfaceParams{`,
  1820  				`type GetInterfaceParams struct {`,
  1821  				"	HTTPRequest *http.Request `json:\"-\"`",
  1822  				`	Generic interface{`,
  1823  				`func (o *GetInterfaceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1824  				`	o.HTTPRequest = r`,
  1825  				`	if runtime.HasBody(r) {`,
  1826  				`		defer r.Body.Close(`,
  1827  				`		var body interface{`,
  1828  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1829  				`			res = append(res, errors.NewParseError("generic", "body", "", err)`,
  1830  				`		} else {`,
  1831  				`			o.Generic = body`,
  1832  				`		return errors.CompositeValidationError(res...`,
  1833  			},
  1834  		},
  1835  
  1836  		// load expectations for parameters in operation get_map_slice_parameters.go
  1837  		"getMapSlice": { // fixture index
  1838  			"serverParameter": { // executed template
  1839  				// expected code lines
  1840  				`func NewGetMapSliceParams() GetMapSliceParams {`,
  1841  				`	return GetMapSliceParams{`,
  1842  				`type GetMapSliceParams struct {`,
  1843  				"	HTTPRequest *http.Request `json:\"-\"`",
  1844  				`	GenericMapSlice []map[string]models.ModelInterface`,
  1845  				`func (o *GetMapSliceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1846  				`	o.HTTPRequest = r`,
  1847  				`	if runtime.HasBody(r) {`,
  1848  				`		defer r.Body.Close(`,
  1849  				`		var body []map[string]models.ModelInterface`,
  1850  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1851  				`			res = append(res, errors.NewParseError("genericMapSlice", "body", "", err)`,
  1852  				`		} else {`,
  1853  				`			o.GenericMapSlice = body`,
  1854  				`		return errors.CompositeValidationError(res...`,
  1855  			},
  1856  		},
  1857  
  1858  		// load expectations for parameters in operation get_nested_with_validations_parameters.go
  1859  		"getNestedWithValidations": { // fixture index
  1860  			"serverParameter": { // executed template
  1861  				// expected code lines
  1862  				`func NewGetNestedWithValidationsParams() GetNestedWithValidationsParams {`,
  1863  				`	return GetNestedWithValidationsParams{`,
  1864  				`type GetNestedWithValidationsParams struct {`,
  1865  				"	HTTPRequest *http.Request `json:\"-\"`",
  1866  				`	GenericNestedWithValidations [][][][]interface{`,
  1867  				`func (o *GetNestedWithValidationsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1868  				`	o.HTTPRequest = r`,
  1869  				`	if runtime.HasBody(r) {`,
  1870  				`		defer r.Body.Close(`,
  1871  				`		var body [][][][]interface{`,
  1872  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1873  				`			res = append(res, errors.NewParseError("genericNestedWithValidations", "body", "", err)`,
  1874  				`		} else {`,
  1875  				`			o.GenericNestedWithValidations = body`,
  1876  				`			if err := o.validateGenericNestedWithValidationsBody(route.Formats); err != nil {`,
  1877  				`		return errors.CompositeValidationError(res...`,
  1878  				`func (o *GetNestedWithValidationsParams) validateGenericNestedWithValidationsBody(formats strfmt.Registry) error {`,
  1879  				`	genericNestedWithValidationsIC := o.GenericNestedWithValidations`,
  1880  				`	var genericNestedWithValidationsIR [][][][]interface{`,
  1881  				`	for i, genericNestedWithValidationsIV := range genericNestedWithValidationsIC {`,
  1882  				`		genericNestedWithValidationsIIC := genericNestedWithValidationsIV`,
  1883  				`		if len(genericNestedWithValidationsIIC) > 0 {`,
  1884  				`			var genericNestedWithValidationsIIR [][][]interface{`,
  1885  				`			for ii, genericNestedWithValidationsIIV := range genericNestedWithValidationsIIC {`,
  1886  				`				genericNestedWithValidationsIIIC := genericNestedWithValidationsIIV`,
  1887  				`				if len(genericNestedWithValidationsIIIC) > 0 {`,
  1888  				`					var genericNestedWithValidationsIIIR [][]interface{`,
  1889  				`					for iii, genericNestedWithValidationsIIIV := range genericNestedWithValidationsIIIC {`,
  1890  				`						genericNestedWithValidationsIIIIC := genericNestedWithValidationsIIIV`,
  1891  				`						if len(genericNestedWithValidationsIIIIC) > 0 {`,
  1892  				`							var genericNestedWithValidationsIIIIR []interface{`,
  1893  				`							for _, genericNestedWithValidationsIIIIV := range genericNestedWithValidationsIIIIC {`,
  1894  				`								genericNestedWithValidationsIIII := genericNestedWithValidationsIIIIV`,
  1895  				`								genericNestedWithValidationsIIIIR = append(genericNestedWithValidationsIIIIR, genericNestedWithValidationsIIII`,
  1896  				`							genericNestedWithValidationsIIIR = append(genericNestedWithValidationsIIIR, genericNestedWithValidationsIIIIR`,
  1897  				`						genericNestedWithValidationsIiiiiiSize := int64(len(genericNestedWithValidationsIIIIC)`,
  1898  				`						if err := validate.MaxItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "genericNestedWithValidations", i), ii), iii), "", genericNestedWithValidationsIiiiiiSize, 10); err != nil {`,
  1899  				`					genericNestedWithValidationsIIR = append(genericNestedWithValidationsIIR, genericNestedWithValidationsIIIR`,
  1900  				`			genericNestedWithValidationsIR = append(genericNestedWithValidationsIR, genericNestedWithValidationsIIR`,
  1901  				`	o.GenericNestedWithValidations = genericNestedWithValidationsIR`,
  1902  			},
  1903  		},
  1904  
  1905  		// load expectations for parameters in operation get_another_interface_parameters.go
  1906  		"getAnotherInterface": { // fixture index
  1907  			"serverParameter": { // executed template
  1908  				// expected code lines
  1909  				`func NewGetAnotherInterfaceParams() GetAnotherInterfaceParams {`,
  1910  				`	return GetAnotherInterfaceParams{`,
  1911  				`type GetAnotherInterfaceParams struct {`,
  1912  				"	HTTPRequest *http.Request `json:\"-\"`",
  1913  				`	AnotherGeneric interface{`,
  1914  				`func (o *GetAnotherInterfaceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1915  				`	o.HTTPRequest = r`,
  1916  				`	if runtime.HasBody(r) {`,
  1917  				`		defer r.Body.Close(`,
  1918  				`		var body interface{`,
  1919  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1920  				`			res = append(res, errors.NewParseError("anotherGeneric", "body", "", err)`,
  1921  				`		} else {`,
  1922  				`			o.AnotherGeneric = body`,
  1923  				`		return errors.CompositeValidationError(res...`,
  1924  			},
  1925  		},
  1926  
  1927  		// load expectations for parameters in operation get_nested_required_parameters.go
  1928  		"getNestedRequired": { // fixture index
  1929  			"serverParameter": { // executed template
  1930  				// expected code lines
  1931  				`func NewGetNestedRequiredParams() GetNestedRequiredParams {`,
  1932  				`	return GetNestedRequiredParams{`,
  1933  				`type GetNestedRequiredParams struct {`,
  1934  				"	HTTPRequest *http.Request `json:\"-\"`",
  1935  				`	ObjectNestedRequired [][][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  1936  				`func (o *GetNestedRequiredParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1937  				`	o.HTTPRequest = r`,
  1938  				`	if runtime.HasBody(r) {`,
  1939  				`		defer r.Body.Close(`,
  1940  				`		var body [][][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  1941  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1942  				`			res = append(res, errors.NewParseError("objectNestedRequired", "body", "", err)`,
  1943  				`		} else {`,
  1944  				`			o.ObjectNestedRequired = body`,
  1945  				`			if err := o.validateObjectNestedRequiredBody(route.Formats); err != nil {`,
  1946  				`		return errors.CompositeValidationError(res...`,
  1947  				`func (o *GetNestedRequiredParams) validateObjectNestedRequiredBody(formats strfmt.Registry) error {`,
  1948  				`	objectNestedRequiredIC := o.ObjectNestedRequired`,
  1949  				`	var objectNestedRequiredIR [][][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  1950  				`	for i, objectNestedRequiredIV := range objectNestedRequiredIC {`,
  1951  				`		objectNestedRequiredIIC := objectNestedRequiredIV`,
  1952  				`		if len(objectNestedRequiredIIC) > 0 {`,
  1953  				`			var objectNestedRequiredIIR [][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  1954  				`			for ii, objectNestedRequiredIIV := range objectNestedRequiredIIC {`,
  1955  				`				objectNestedRequiredIIIC := objectNestedRequiredIIV`,
  1956  				`				if len(objectNestedRequiredIIIC) > 0 {`,
  1957  				`					var objectNestedRequiredIIIR [][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  1958  				`					for iii, objectNestedRequiredIIIV := range objectNestedRequiredIIIC {`,
  1959  				`						objectNestedRequiredIIIIC := objectNestedRequiredIIIV`,
  1960  				`						if len(objectNestedRequiredIIIIC) > 0 {`,
  1961  				`							var objectNestedRequiredIIIIR []*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  1962  				`							for iiii, objectNestedRequiredIIIIV := range objectNestedRequiredIIIIC {`,
  1963  				`								objectNestedRequiredIIII := objectNestedRequiredIIIIV`,
  1964  				`								if err := objectNestedRequiredIIII.Validate(formats); err != nil {`,
  1965  				`									if ve, ok := err.(*errors.Validation); ok {`,
  1966  				`										return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "objectNestedRequired", i), ii), iii), iiii)`,
  1967  				`								objectNestedRequiredIIIIR = append(objectNestedRequiredIIIIR, objectNestedRequiredIIII`,
  1968  				`							objectNestedRequiredIIIR = append(objectNestedRequiredIIIR, objectNestedRequiredIIIIR`,
  1969  				`					objectNestedRequiredIIR = append(objectNestedRequiredIIR, objectNestedRequiredIIIR`,
  1970  				`			objectNestedRequiredIR = append(objectNestedRequiredIR, objectNestedRequiredIIR`,
  1971  				`	o.ObjectNestedRequired = objectNestedRequiredIR`,
  1972  			},
  1973  		},
  1974  
  1975  		// load expectations for parameters in operation get_records_max_parameters.go
  1976  		"getRecordsMax": { // fixture index
  1977  			"serverParameter": { // executed template
  1978  				// expected code lines
  1979  				`func NewGetRecordsMaxParams() GetRecordsMaxParams {`,
  1980  				`	return GetRecordsMaxParams{`,
  1981  				`type GetRecordsMaxParams struct {`,
  1982  				"	HTTPRequest *http.Request `json:\"-\"`",
  1983  				`	MaxRecords []interface{`,
  1984  				`func (o *GetRecordsMaxParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  1985  				`	o.HTTPRequest = r`,
  1986  				`	if runtime.HasBody(r) {`,
  1987  				`		defer r.Body.Close(`,
  1988  				`		var body []interface{`,
  1989  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  1990  				`			if err == io.EOF {`,
  1991  				`				res = append(res, errors.Required("maxRecords", "body")`,
  1992  				`			} else {`,
  1993  				`				res = append(res, errors.NewParseError("maxRecords", "body", "", err)`,
  1994  				`		} else {`,
  1995  				`			o.MaxRecords = body`,
  1996  				`			if err := o.validateMaxRecordsBody(route.Formats); err != nil {`,
  1997  				`	} else {`,
  1998  				`		res = append(res, errors.Required("maxRecords", "body")`,
  1999  				`		return errors.CompositeValidationError(res...`,
  2000  				`func (o *GetRecordsMaxParams) validateMaxRecordsBody(formats strfmt.Registry) error {`,
  2001  				`	maxRecordsSize := int64(len(o.MaxRecords)`,
  2002  				`	if err := validate.MaxItems("maxRecords", "body", maxRecordsSize, 10); err != nil {`,
  2003  			},
  2004  		},
  2005  
  2006  		// load expectations for parameters in operation get_records_parameters.go
  2007  		"getRecords": { // fixture index
  2008  			"serverParameter": { // executed template
  2009  				// expected code lines
  2010  				`func NewGetRecordsParams() GetRecordsParams {`,
  2011  				`	return GetRecordsParams{`,
  2012  				`type GetRecordsParams struct {`,
  2013  				"	HTTPRequest *http.Request `json:\"-\"`",
  2014  				`	Records []interface{`,
  2015  				`func (o *GetRecordsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2016  				`	o.HTTPRequest = r`,
  2017  				`	if runtime.HasBody(r) {`,
  2018  				`		defer r.Body.Close(`,
  2019  				`		var body []interface{`,
  2020  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2021  				`			if err == io.EOF {`,
  2022  				`				res = append(res, errors.Required("records", "body")`,
  2023  				`			} else {`,
  2024  				`				res = append(res, errors.NewParseError("records", "body", "", err)`,
  2025  				`		} else {`,
  2026  				`			o.Records = body`,
  2027  				// fixed: no validation has to be carried on
  2028  				`	} else {`,
  2029  				`		res = append(res, errors.Required("records", "body")`,
  2030  				`		return errors.CompositeValidationError(res...`,
  2031  			},
  2032  		},
  2033  		// load expectations for parameters in operation get_records_non_required_parameters.go
  2034  		"getRecordsNonRequired": { // fixture index
  2035  			"serverParameter": { // executed template
  2036  				// expected code lines
  2037  				`func NewGetRecordsNonRequiredParams() GetRecordsNonRequiredParams {`,
  2038  				`	return GetRecordsNonRequiredParams{`,
  2039  				`type GetRecordsNonRequiredParams struct {`,
  2040  				"	HTTPRequest *http.Request `json:\"-\"`",
  2041  				`	RecordsNonRequired []interface{`,
  2042  				`func (o *GetRecordsNonRequiredParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2043  				`	o.HTTPRequest = r`,
  2044  				`	if runtime.HasBody(r) {`,
  2045  				`		defer r.Body.Close(`,
  2046  				`		var body []interface{`,
  2047  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2048  				`			res = append(res, errors.NewParseError("recordsNonRequired", "body", "", err)`,
  2049  				`		} else {`,
  2050  				`			o.RecordsNonRequired = body`,
  2051  				`		return errors.CompositeValidationError(res...`,
  2052  			},
  2053  		},
  2054  		// load expectations for parameters in operation get_map_parameters.go
  2055  		"getMap": { // fixture index
  2056  			"serverParameter": { // executed template
  2057  				// expected code lines
  2058  				`func NewGetMapParams() GetMapParams {`,
  2059  				`	return GetMapParams{`,
  2060  				`type GetMapParams struct {`,
  2061  				"	HTTPRequest *http.Request `json:\"-\"`",
  2062  				`	GenericMap map[string]models.ModelInterface`,
  2063  				`func (o *GetMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2064  				`	o.HTTPRequest = r`,
  2065  				`	if runtime.HasBody(r) {`,
  2066  				`		defer r.Body.Close(`,
  2067  				`		var body map[string]models.ModelInterface`,
  2068  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2069  				`			res = append(res, errors.NewParseError("genericMap", "body", "", err)`,
  2070  				`		} else {`,
  2071  				`			o.GenericMap = body`,
  2072  				`		return errors.CompositeValidationError(res...`,
  2073  			},
  2074  		},
  2075  
  2076  		// load expectations for parameters in operation get_slice_map_parameters.go
  2077  		"getSliceMap": { // fixture index
  2078  			"serverParameter": { // executed template
  2079  				// expected code lines
  2080  				`func NewGetSliceMapParams() GetSliceMapParams {`,
  2081  				`	return GetSliceMapParams{`,
  2082  				`type GetSliceMapParams struct {`,
  2083  				"	HTTPRequest *http.Request `json:\"-\"`",
  2084  				`	GenericSliceMap map[string][]models.ModelInterface`,
  2085  				`func (o *GetSliceMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2086  				`	o.HTTPRequest = r`,
  2087  				`	if runtime.HasBody(r) {`,
  2088  				`		defer r.Body.Close(`,
  2089  				`		var body map[string][]models.ModelInterface`,
  2090  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2091  				`			res = append(res, errors.NewParseError("genericSliceMap", "body", "", err)`,
  2092  				`		} else {`,
  2093  				`			o.GenericSliceMap = body`,
  2094  				`		return errors.CompositeValidationError(res...`,
  2095  			},
  2096  		},
  2097  
  2098  		// load expectations for parameters in operation get_nested_parameters.go
  2099  		"getNested": { // fixture index
  2100  			"serverParameter": { // executed template
  2101  				// expected code lines
  2102  				`func NewGetNestedParams() GetNestedParams {`,
  2103  				`	return GetNestedParams{`,
  2104  				`type GetNestedParams struct {`,
  2105  				"	HTTPRequest *http.Request `json:\"-\"`",
  2106  				`	GenericNested [][][][]interface{`,
  2107  				`func (o *GetNestedParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2108  				`	o.HTTPRequest = r`,
  2109  				`	if runtime.HasBody(r) {`,
  2110  				`		defer r.Body.Close(`,
  2111  				`		var body [][][][]interface{`,
  2112  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2113  				`			res = append(res, errors.NewParseError("genericNested", "body", "", err)`,
  2114  				`		} else {`,
  2115  				`			o.GenericNested = body`,
  2116  				`		return errors.CompositeValidationError(res...`,
  2117  			},
  2118  		},
  2119  	}
  2120  
  2121  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1536", "fixture-1536.yaml"), false, false)
  2122  }
  2123  
  2124  func TestGenParameter_Issue15362(t *testing.T) {
  2125  	log.SetOutput(ioutil.Discard)
  2126  	defer func() {
  2127  		log.SetOutput(os.Stdout)
  2128  	}()
  2129  
  2130  	fixtureConfig := map[string]map[string][]string{
  2131  		// load expectations for parameters in operation get_nested_with_validations_parameters.go
  2132  		"getNestedWithValidations": { // fixture index
  2133  			"serverParameter": { // executed template
  2134  				// expected code lines
  2135  				`func NewGetNestedWithValidationsParams() GetNestedWithValidationsParams {`,
  2136  				`	return GetNestedWithValidationsParams{`,
  2137  				`type GetNestedWithValidationsParams struct {`,
  2138  				"	HTTPRequest *http.Request `json:\"-\"`",
  2139  				`	GenericNestedWithValidations [][][][]interface{`,
  2140  				`func (o *GetNestedWithValidationsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2141  				`	o.HTTPRequest = r`,
  2142  				`	if runtime.HasBody(r) {`,
  2143  				`		defer r.Body.Close(`,
  2144  				`		var body [][][][]interface{`,
  2145  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2146  				`			res = append(res, errors.NewParseError("genericNestedWithValidations", "body", "", err)`,
  2147  				`		} else {`,
  2148  				`			o.GenericNestedWithValidations = body`,
  2149  				`			if err := o.validateGenericNestedWithValidationsBody(route.Formats); err != nil {`,
  2150  				`		return errors.CompositeValidationError(res...`,
  2151  				`func (o *GetNestedWithValidationsParams) validateGenericNestedWithValidationsBody(formats strfmt.Registry) error {`,
  2152  				`	genericNestedWithValidationsIC := o.GenericNestedWithValidations`,
  2153  				`	var genericNestedWithValidationsIR [][][][]interface{`,
  2154  				`	for i, genericNestedWithValidationsIV := range genericNestedWithValidationsIC {`,
  2155  				`		genericNestedWithValidationsIIC := genericNestedWithValidationsIV`,
  2156  				`		if len(genericNestedWithValidationsIIC) > 0 {`,
  2157  				`			var genericNestedWithValidationsIIR [][][]interface{`,
  2158  				`			for ii, genericNestedWithValidationsIIV := range genericNestedWithValidationsIIC {`,
  2159  				`				genericNestedWithValidationsIIIC := genericNestedWithValidationsIIV`,
  2160  				`				if len(genericNestedWithValidationsIIIC) > 0 {`,
  2161  				`					var genericNestedWithValidationsIIIR [][]interface{`,
  2162  				`					for iii, genericNestedWithValidationsIIIV := range genericNestedWithValidationsIIIC {`,
  2163  				`						genericNestedWithValidationsIIIIC := genericNestedWithValidationsIIIV`,
  2164  				`						if len(genericNestedWithValidationsIIIIC) > 0 {`,
  2165  				`							var genericNestedWithValidationsIIIIR []interface{`,
  2166  				`							for _, genericNestedWithValidationsIIIIV := range genericNestedWithValidationsIIIIC {`,
  2167  				`								genericNestedWithValidationsIIII := genericNestedWithValidationsIIIIV`,
  2168  				`								genericNestedWithValidationsIIIIR = append(genericNestedWithValidationsIIIIR, genericNestedWithValidationsIIII`,
  2169  				`							genericNestedWithValidationsIIIR = append(genericNestedWithValidationsIIIR, genericNestedWithValidationsIIIIR`,
  2170  				`						genericNestedWithValidationsIiiiiiSize := int64(len(genericNestedWithValidationsIIIIC)`,
  2171  				`						if err := validate.MaxItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "genericNestedWithValidations", i), ii), iii), "", genericNestedWithValidationsIiiiiiSize, 10); err != nil {`,
  2172  				`					genericNestedWithValidationsIIR = append(genericNestedWithValidationsIIR, genericNestedWithValidationsIIIR`,
  2173  				`			genericNestedWithValidationsIR = append(genericNestedWithValidationsIR, genericNestedWithValidationsIIR`,
  2174  				`	o.GenericNestedWithValidations = genericNestedWithValidationsIR`,
  2175  			},
  2176  		},
  2177  
  2178  		// load expectations for parameters in operation get_nested_required_parameters.go
  2179  		"getNestedRequired": { // fixture index
  2180  			"serverParameter": { // executed template
  2181  				// expected code lines
  2182  				`func NewGetNestedRequiredParams() GetNestedRequiredParams {`,
  2183  				`	return GetNestedRequiredParams{`,
  2184  				`type GetNestedRequiredParams struct {`,
  2185  				"	HTTPRequest *http.Request `json:\"-\"`",
  2186  				`	ObjectNestedRequired [][][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  2187  				`func (o *GetNestedRequiredParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2188  				`	o.HTTPRequest = r`,
  2189  				`	if runtime.HasBody(r) {`,
  2190  				`		defer r.Body.Close(`,
  2191  				`		var body [][][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  2192  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2193  				`			res = append(res, errors.NewParseError("objectNestedRequired", "body", "", err)`,
  2194  				`		} else {`,
  2195  				`			o.ObjectNestedRequired = body`,
  2196  				`			if err := o.validateObjectNestedRequiredBody(route.Formats); err != nil {`,
  2197  				`		return errors.CompositeValidationError(res...`,
  2198  				`func (o *GetNestedRequiredParams) validateObjectNestedRequiredBody(formats strfmt.Registry) error {`,
  2199  				`	objectNestedRequiredIC := o.ObjectNestedRequired`,
  2200  				`	var objectNestedRequiredIR [][][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  2201  				`	for i, objectNestedRequiredIV := range objectNestedRequiredIC {`,
  2202  				`		objectNestedRequiredIIC := objectNestedRequiredIV`,
  2203  				`		if len(objectNestedRequiredIIC) > 0 {`,
  2204  				`			var objectNestedRequiredIIR [][][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  2205  				`			for ii, objectNestedRequiredIIV := range objectNestedRequiredIIC {`,
  2206  				`				objectNestedRequiredIIIC := objectNestedRequiredIIV`,
  2207  				`				if len(objectNestedRequiredIIIC) > 0 {`,
  2208  				`					var objectNestedRequiredIIIR [][]*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  2209  				`					for iii, objectNestedRequiredIIIV := range objectNestedRequiredIIIC {`,
  2210  				`						objectNestedRequiredIIIIC := objectNestedRequiredIIIV`,
  2211  				`						if len(objectNestedRequiredIIIIC) > 0 {`,
  2212  				`							var objectNestedRequiredIIIIR []*models.GetNestedRequiredParamsBodyItemsItemsItemsItems`,
  2213  				`							for iiii, objectNestedRequiredIIIIV := range objectNestedRequiredIIIIC {`,
  2214  				`								if objectNestedRequiredIIIIV == nil {`,
  2215  				// 										continue
  2216  				`									objectNestedRequiredIIII := objectNestedRequiredIIIIV`,
  2217  				`									if err := objectNestedRequiredIIII.Validate(formats); err != nil {`,
  2218  				`										if ve, ok := err.(*errors.Validation); ok {`,
  2219  				`											return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "objectNestedRequired", i), ii), iii), iiii)`,
  2220  				`								objectNestedRequiredIIIIR = append(objectNestedRequiredIIIIR, objectNestedRequiredIIII`,
  2221  				`							objectNestedRequiredIIIR = append(objectNestedRequiredIIIR, objectNestedRequiredIIIIR`,
  2222  				`					objectNestedRequiredIIR = append(objectNestedRequiredIIR, objectNestedRequiredIIIR`,
  2223  				`			objectNestedRequiredIR = append(objectNestedRequiredIR, objectNestedRequiredIIR`,
  2224  				`	o.ObjectNestedRequired = objectNestedRequiredIR`,
  2225  			},
  2226  		},
  2227  
  2228  		// load expectations for parameters in operation get_simple_array_with_slice_validation_parameters.go
  2229  		"getSimpleArrayWithSliceValidation": { // fixture index
  2230  			"serverParameter": { // executed template
  2231  				// expected code lines
  2232  				`func NewGetSimpleArrayWithSliceValidationParams() GetSimpleArrayWithSliceValidationParams {`,
  2233  				`	return GetSimpleArrayWithSliceValidationParams{`,
  2234  				`type GetSimpleArrayWithSliceValidationParams struct {`,
  2235  				"	HTTPRequest *http.Request `json:\"-\"`",
  2236  				`	SimpleArrayWithSliceValidation []int64`,
  2237  				`func (o *GetSimpleArrayWithSliceValidationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2238  				`	o.HTTPRequest = r`,
  2239  				`	if runtime.HasBody(r) {`,
  2240  				`		defer r.Body.Close(`,
  2241  				`		var body []int64`,
  2242  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2243  				`			res = append(res, errors.NewParseError("simpleArrayWithSliceValidation", "body", "", err)`,
  2244  				`		} else {`,
  2245  				`			o.SimpleArrayWithSliceValidation = body`,
  2246  				`			if err := o.validateSimpleArrayWithSliceValidationBody(route.Formats); err != nil {`,
  2247  				`		return errors.CompositeValidationError(res...`,
  2248  				`func (o *GetSimpleArrayWithSliceValidationParams) validateSimpleArrayWithSliceValidationBody(formats strfmt.Registry) error {`,
  2249  				`	if err := validate.Enum("simpleArrayWithSliceValidation", "body", o.SimpleArrayWithSliceValidation, []interface{}{[]interface{}{1, 2, 3}, []interface{}{4, 5, 6}}); err != nil {`,
  2250  			},
  2251  		},
  2252  
  2253  		// load expectations for parameters in operation get_simple_parameters.go
  2254  		"getSimple": { // fixture index
  2255  			"serverParameter": { // executed template
  2256  				// expected code lines
  2257  				`func NewGetSimpleParams() GetSimpleParams {`,
  2258  				`	return GetSimpleParams{`,
  2259  				`type GetSimpleParams struct {`,
  2260  				"	HTTPRequest *http.Request `json:\"-\"`",
  2261  				`	SimpleBody *models.GetSimpleParamsBody`,
  2262  				`func (o *GetSimpleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2263  				`	o.HTTPRequest = r`,
  2264  				`	if runtime.HasBody(r) {`,
  2265  				`		defer r.Body.Close(`,
  2266  				`		var body models.GetSimpleParamsBody`,
  2267  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2268  				`			res = append(res, errors.NewParseError("simpleBody", "body", "", err)`,
  2269  				`		} else {`,
  2270  				`			if err := body.Validate(route.Formats); err != nil {`,
  2271  				`			if len(res) == 0 {`,
  2272  				`				o.SimpleBody = &body`,
  2273  				`		return errors.CompositeValidationError(res...`,
  2274  			},
  2275  		},
  2276  
  2277  		// load expectations for parameters in operation get_simple_array_with_validation_parameters.go
  2278  		"getSimpleArrayWithValidation": { // fixture index
  2279  			"serverParameter": { // executed template
  2280  				// expected code lines
  2281  				`func NewGetSimpleArrayWithValidationParams() GetSimpleArrayWithValidationParams {`,
  2282  				`	return GetSimpleArrayWithValidationParams{`,
  2283  				`type GetSimpleArrayWithValidationParams struct {`,
  2284  				"	HTTPRequest *http.Request `json:\"-\"`",
  2285  				`	SimpleArrayWithValidation []int64`,
  2286  				`func (o *GetSimpleArrayWithValidationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2287  				`	o.HTTPRequest = r`,
  2288  				`	if runtime.HasBody(r) {`,
  2289  				`		defer r.Body.Close(`,
  2290  				`		var body []int64`,
  2291  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2292  				`			res = append(res, errors.NewParseError("simpleArrayWithValidation", "body", "", err)`,
  2293  				`		} else {`,
  2294  				`			o.SimpleArrayWithValidation = body`,
  2295  				`			if err := o.validateSimpleArrayWithValidationBody(route.Formats); err != nil {`,
  2296  				`		return errors.CompositeValidationError(res...`,
  2297  				`func (o *GetSimpleArrayWithValidationParams) validateSimpleArrayWithValidationBody(formats strfmt.Registry) error {`,
  2298  				`	simpleArrayWithValidationIC := o.SimpleArrayWithValidation`,
  2299  				`	var simpleArrayWithValidationIR []int64`,
  2300  				`	for i, simpleArrayWithValidationIV := range simpleArrayWithValidationIC {`,
  2301  				`		simpleArrayWithValidationI := simpleArrayWithValidationIV`,
  2302  				`		if err := validate.MaximumInt(fmt.Sprintf("%s.%v", "simpleArrayWithValidation", i), "body", int64(simpleArrayWithValidationI), 12, false); err != nil {`,
  2303  				`		simpleArrayWithValidationIR = append(simpleArrayWithValidationIR, simpleArrayWithValidationI`,
  2304  				`	o.SimpleArrayWithValidation = simpleArrayWithValidationIR`,
  2305  			},
  2306  		},
  2307  
  2308  		// load expectations for parameters in operation get_nested_parameters.go
  2309  		"getNested": { // fixture index
  2310  			"serverParameter": { // executed template
  2311  				// expected code lines
  2312  				`func NewGetNestedParams() GetNestedParams {`,
  2313  				`	return GetNestedParams{`,
  2314  				`type GetNestedParams struct {`,
  2315  				"	HTTPRequest *http.Request `json:\"-\"`",
  2316  				`	GenericNested [][][][]interface{`,
  2317  				`func (o *GetNestedParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2318  				`	o.HTTPRequest = r`,
  2319  				`	if runtime.HasBody(r) {`,
  2320  				`		defer r.Body.Close(`,
  2321  				`		var body [][][][]interface{`,
  2322  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2323  				`			res = append(res, errors.NewParseError("genericNested", "body", "", err)`,
  2324  				`		} else {`,
  2325  				`			o.GenericNested = body`,
  2326  				`		return errors.CompositeValidationError(res...`,
  2327  			},
  2328  		},
  2329  
  2330  		// load expectations for parameters in operation get_simple_array_parameters.go
  2331  		"getSimpleArray": { // fixture index
  2332  			"serverParameter": { // executed template
  2333  				// expected code lines
  2334  				`func NewGetSimpleArrayParams() GetSimpleArrayParams {`,
  2335  				`	return GetSimpleArrayParams{`,
  2336  				`type GetSimpleArrayParams struct {`,
  2337  				"	HTTPRequest *http.Request `json:\"-\"`",
  2338  				`	SimpleArray []int64`,
  2339  				`func (o *GetSimpleArrayParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2340  				`	o.HTTPRequest = r`,
  2341  				`	if runtime.HasBody(r) {`,
  2342  				`		defer r.Body.Close(`,
  2343  				`		var body []int64`,
  2344  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2345  				`			res = append(res, errors.NewParseError("simpleArray", "body", "", err)`,
  2346  				`		} else {`,
  2347  				`			o.SimpleArray = body`,
  2348  				`		return errors.CompositeValidationError(res...`,
  2349  			},
  2350  		},
  2351  	}
  2352  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1536", "fixture-1536-2.yaml"), false, false)
  2353  }
  2354  
  2355  func TestGenParameter_Issue1536_Maps(t *testing.T) {
  2356  	log.SetOutput(ioutil.Discard)
  2357  	defer func() {
  2358  		log.SetOutput(os.Stdout)
  2359  	}()
  2360  
  2361  	fixtureConfig := map[string]map[string][]string{
  2362  
  2363  		// load expectations for parameters in operation get_map_interface_parameters.go
  2364  		"getMapInterface": { // fixture index
  2365  			"serverParameter": { // executed template
  2366  				// expected code lines
  2367  				`func NewGetMapInterfaceParams() GetMapInterfaceParams {`,
  2368  				`	return GetMapInterfaceParams{`,
  2369  				`type GetMapInterfaceParams struct {`,
  2370  				"	HTTPRequest *http.Request `json:\"-\"`",
  2371  				`	MapOfInterface map[string]models.ModelInterface`,
  2372  				`func (o *GetMapInterfaceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2373  				`	o.HTTPRequest = r`,
  2374  				`	if runtime.HasBody(r) {`,
  2375  				`		defer r.Body.Close(`,
  2376  				`		var body map[string]models.ModelInterface`,
  2377  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2378  				`			if err == io.EOF {`,
  2379  				`				res = append(res, errors.Required("mapOfInterface", "body")`,
  2380  				`			} else {`,
  2381  				`				res = append(res, errors.NewParseError("mapOfInterface", "body", "", err)`,
  2382  				`		} else {`,
  2383  				`			o.MapOfInterface = body`,
  2384  				`	} else {`,
  2385  				`		res = append(res, errors.Required("mapOfInterface", "body")`,
  2386  				`		return errors.CompositeValidationError(res...`,
  2387  			},
  2388  		},
  2389  
  2390  		// load expectations for parameters in operation get_array_of_interface_parameters.go
  2391  		"getArrayOfInterface": { // fixture index
  2392  			"serverParameter": { // executed template
  2393  				// expected code lines
  2394  				`func NewGetArrayOfInterfaceParams() GetArrayOfInterfaceParams {`,
  2395  				`	return GetArrayOfInterfaceParams{`,
  2396  				`type GetArrayOfInterfaceParams struct {`,
  2397  				"	HTTPRequest *http.Request `json:\"-\"`",
  2398  				`	ArrayOfInterface []interface{`,
  2399  				`func (o *GetArrayOfInterfaceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2400  				`	o.HTTPRequest = r`,
  2401  				`	if runtime.HasBody(r) {`,
  2402  				`		defer r.Body.Close(`,
  2403  				`		var body []interface{`,
  2404  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2405  				`			if err == io.EOF {`,
  2406  				`				res = append(res, errors.Required("arrayOfInterface", "body")`,
  2407  				`			} else {`,
  2408  				`				res = append(res, errors.NewParseError("arrayOfInterface", "body", "", err)`,
  2409  				`		} else {`,
  2410  				`			o.ArrayOfInterface = body`,
  2411  				`	} else {`,
  2412  				`		res = append(res, errors.Required("arrayOfInterface", "body")`,
  2413  				`		return errors.CompositeValidationError(res...`,
  2414  			},
  2415  		},
  2416  
  2417  		// load expectations for parameters in operation get_map_array_with_max_parameters.go
  2418  		"getMapArrayWithMax": { // fixture index
  2419  			"serverParameter": { // executed template
  2420  				// expected code lines
  2421  				`func NewGetMapArrayWithMaxParams() GetMapArrayWithMaxParams {`,
  2422  				`	return GetMapArrayWithMaxParams{`,
  2423  				`type GetMapArrayWithMaxParams struct {`,
  2424  				"	HTTPRequest *http.Request `json:\"-\"`",
  2425  				`	MapOfArrayWithMax map[string]models.ModelArrayWithMax`,
  2426  				`func (o *GetMapArrayWithMaxParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2427  				`	o.HTTPRequest = r`,
  2428  				`	if runtime.HasBody(r) {`,
  2429  				`		defer r.Body.Close(`,
  2430  				`		var body map[string]models.ModelArrayWithMax`,
  2431  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2432  				`			if err == io.EOF {`,
  2433  				`				res = append(res, errors.Required("mapOfArrayWithMax", "body")`,
  2434  				`			} else {`,
  2435  				`				res = append(res, errors.NewParseError("mapOfArrayWithMax", "body", "", err)`,
  2436  				`		} else {`,
  2437  				`			for k := range body {`,
  2438  				`				if val, ok := body[k]; ok {`,
  2439  				`				if err := val.Validate(route.Formats); err != nil {`,
  2440  				`					break`,
  2441  				`			if len(res) == 0 {`,
  2442  				`				o.MapOfArrayWithMax = body`,
  2443  				`	} else {`,
  2444  				`		res = append(res, errors.Required("mapOfArrayWithMax", "body")`,
  2445  				`		return errors.CompositeValidationError(res...`,
  2446  			},
  2447  		},
  2448  
  2449  		// load expectations for parameters in operation get_array_nested_simple_parameters.go
  2450  		"getArrayNestedSimple": { // fixture index
  2451  			"serverParameter": { // executed template
  2452  				// expected code lines
  2453  				`func NewGetArrayNestedSimpleParams() GetArrayNestedSimpleParams {`,
  2454  				`	return GetArrayNestedSimpleParams{`,
  2455  				`type GetArrayNestedSimpleParams struct {`,
  2456  				"	HTTPRequest *http.Request `json:\"-\"`",
  2457  				`	ArrayOfarraySimple [][]string`,
  2458  				`func (o *GetArrayNestedSimpleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2459  				`	o.HTTPRequest = r`,
  2460  				`	if runtime.HasBody(r) {`,
  2461  				`		defer r.Body.Close(`,
  2462  				`		var body [][]string`,
  2463  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2464  				`			if err == io.EOF {`,
  2465  				`				res = append(res, errors.Required("arrayOfarraySimple", "body")`,
  2466  				`			} else {`,
  2467  				`				res = append(res, errors.NewParseError("arrayOfarraySimple", "body", "", err)`,
  2468  				`		} else {`,
  2469  				`			o.ArrayOfarraySimple = body`,
  2470  				`			if err := o.validateArrayOfarraySimpleBody(route.Formats); err != nil {`,
  2471  				`	} else {`,
  2472  				`		res = append(res, errors.Required("arrayOfarraySimple", "body")`,
  2473  				`		return errors.CompositeValidationError(res...`,
  2474  				`func (o *GetArrayNestedSimpleParams) validateArrayOfarraySimpleBody(formats strfmt.Registry) error {`,
  2475  				`	arrayOfarraySimpleIC := o.ArrayOfarraySimple`,
  2476  				`	var arrayOfarraySimpleIR [][]string`,
  2477  				`	for i, arrayOfarraySimpleIV := range arrayOfarraySimpleIC {`,
  2478  				`		arrayOfarraySimpleIIC := arrayOfarraySimpleIV`,
  2479  				`		if len(arrayOfarraySimpleIIC) > 0 {`,
  2480  				`			var arrayOfarraySimpleIIR []string`,
  2481  				`			for ii, arrayOfarraySimpleIIV := range arrayOfarraySimpleIIC {`,
  2482  				`				arrayOfarraySimpleII := arrayOfarraySimpleIIV`,
  2483  				`				if err := validate.MaxLength(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "arrayOfarraySimple", i), ii), "", arrayOfarraySimpleII, 100); err != nil {`,
  2484  				`				arrayOfarraySimpleIIR = append(arrayOfarraySimpleIIR, arrayOfarraySimpleII`,
  2485  				`			arrayOfarraySimpleIR = append(arrayOfarraySimpleIR, arrayOfarraySimpleIIR`,
  2486  				`	o.ArrayOfarraySimple = arrayOfarraySimpleIR`,
  2487  			},
  2488  		},
  2489  
  2490  		// load expectations for parameters in operation get_map_of_format_parameters.go
  2491  		"getMapOfFormat": { // fixture index
  2492  			"serverParameter": { // executed template
  2493  				// expected code lines
  2494  				`func NewGetMapOfFormatParams() GetMapOfFormatParams {`,
  2495  				`	return GetMapOfFormatParams{`,
  2496  				`type GetMapOfFormatParams struct {`,
  2497  				"	HTTPRequest *http.Request `json:\"-\"`",
  2498  				`	MapOfFormat map[string]strfmt.UUID`,
  2499  				`func (o *GetMapOfFormatParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2500  				`	o.HTTPRequest = r`,
  2501  				`	if runtime.HasBody(r) {`,
  2502  				`		defer r.Body.Close(`,
  2503  				`		var body map[string]strfmt.UUID`,
  2504  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2505  				`			if err == io.EOF {`,
  2506  				`				res = append(res, errors.Required("mapOfFormat", "body")`,
  2507  				`			} else {`,
  2508  				`				res = append(res, errors.NewParseError("mapOfFormat", "body", "", err)`,
  2509  				`		} else {`,
  2510  				`			o.MapOfFormat = body`,
  2511  				`			if err := o.validateMapOfFormatBody(route.Formats); err != nil {`,
  2512  				`	} else {`,
  2513  				`		res = append(res, errors.Required("mapOfFormat", "body")`,
  2514  				`		return errors.CompositeValidationError(res...`,
  2515  				`func (o *GetMapOfFormatParams) validateMapOfFormatBody(formats strfmt.Registry) error {`,
  2516  				`	mapOfFormatIC := o.MapOfFormat`,
  2517  				`	mapOfFormatIR := make(map[string]strfmt.UUID, len(mapOfFormatIC)`,
  2518  				`	for k, mapOfFormatIV := range mapOfFormatIC {`,
  2519  				`		mapOfFormatI := mapOfFormatIV`,
  2520  				`		if err := validate.FormatOf(fmt.Sprintf("%s.%v", "mapOfFormat", k), "body", "uuid", mapOfFormatI.String(), formats); err != nil {`,
  2521  				`		mapOfFormatIR[k] = mapOfFormatI`,
  2522  				`	o.MapOfFormat = mapOfFormatIR`,
  2523  			},
  2524  		},
  2525  
  2526  		// load expectations for parameters in operation get_array_of_map_parameters.go
  2527  		"getArrayOfMap": { // fixture index
  2528  			"serverParameter": { // executed template
  2529  				// expected code lines
  2530  				`func NewGetArrayOfMapParams() GetArrayOfMapParams {`,
  2531  				`	return GetArrayOfMapParams{`,
  2532  				`type GetArrayOfMapParams struct {`,
  2533  				"	HTTPRequest *http.Request `json:\"-\"`",
  2534  				`	ArrayOfMap []map[string][]int32`,
  2535  				`func (o *GetArrayOfMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2536  				`	o.HTTPRequest = r`,
  2537  				`	if runtime.HasBody(r) {`,
  2538  				`		defer r.Body.Close(`,
  2539  				`		var body []map[string][]int32`,
  2540  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2541  				`			if err == io.EOF {`,
  2542  				`				res = append(res, errors.Required("arrayOfMap", "body")`,
  2543  				`			} else {`,
  2544  				`				res = append(res, errors.NewParseError("arrayOfMap", "body", "", err)`,
  2545  				`		} else {`,
  2546  				`			o.ArrayOfMap = body`,
  2547  				`			if err := o.validateArrayOfMapBody(route.Formats); err != nil {`,
  2548  				`	} else {`,
  2549  				`		res = append(res, errors.Required("arrayOfMap", "body")`,
  2550  				`		return errors.CompositeValidationError(res...`,
  2551  				`func (o *GetArrayOfMapParams) validateArrayOfMapBody(formats strfmt.Registry) error {`,
  2552  				`	arrayOfMapSize := int64(len(o.ArrayOfMap)`,
  2553  				`	if err := validate.MaxItems("arrayOfMap", "body", arrayOfMapSize, 50); err != nil {`,
  2554  				`	arrayOfMapIC := o.ArrayOfMap`,
  2555  				`	var arrayOfMapIR []map[string][]int32`,
  2556  				`	for i, arrayOfMapIV := range arrayOfMapIC {`,
  2557  				`		arrayOfMapIIC := arrayOfMapIV`,
  2558  				`		arrayOfMapIIR := make(map[string][]int32, len(arrayOfMapIIC)`,
  2559  				`		for kk, arrayOfMapIIV := range arrayOfMapIIC {`,
  2560  				`			arrayOfMapIIIC := arrayOfMapIIV`,
  2561  				`			var arrayOfMapIIIR []int32`,
  2562  				`			for iii, arrayOfMapIIIV := range arrayOfMapIIIC {`,
  2563  				`				arrayOfMapIII := arrayOfMapIIIV`,
  2564  				`				if err := validate.MaximumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "arrayOfMap", i), kk), iii), "", int64(arrayOfMapIII), 100, false); err != nil {`,
  2565  				`				arrayOfMapIIIR = append(arrayOfMapIIIR, arrayOfMapIII`,
  2566  				`			arrayOfMapIIR[kk] = arrayOfMapIIIR`,
  2567  				`		arrayOfMapIR = append(arrayOfMapIR, arrayOfMapIIR`,
  2568  				`	o.ArrayOfMap = arrayOfMapIR`,
  2569  			},
  2570  		},
  2571  
  2572  		// load expectations for parameters in operation get_map_anon_array_with_x_nullable_parameters.go
  2573  		"getMapAnonArrayWithXNullable": { // fixture index
  2574  			"serverParameter": { // executed template
  2575  				// expected code lines
  2576  				`func NewGetMapAnonArrayWithXNullableParams() GetMapAnonArrayWithXNullableParams {`,
  2577  				`	return GetMapAnonArrayWithXNullableParams{`,
  2578  				`type GetMapAnonArrayWithXNullableParams struct {`,
  2579  				"	HTTPRequest *http.Request `json:\"-\"`",
  2580  				`	MapOfAnonArrayWithXNullable map[string][]*int64`,
  2581  				`func (o *GetMapAnonArrayWithXNullableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2582  				`	o.HTTPRequest = r`,
  2583  				`	if runtime.HasBody(r) {`,
  2584  				`		defer r.Body.Close(`,
  2585  				`		var body map[string][]*int64`,
  2586  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2587  				`			if err == io.EOF {`,
  2588  				`				res = append(res, errors.Required("mapOfAnonArrayWithXNullable", "body")`,
  2589  				`			} else {`,
  2590  				`				res = append(res, errors.NewParseError("mapOfAnonArrayWithXNullable", "body", "", err)`,
  2591  				`		} else {`,
  2592  				`			o.MapOfAnonArrayWithXNullable = body`,
  2593  				`	} else {`,
  2594  				`		res = append(res, errors.Required("mapOfAnonArrayWithXNullable", "body")`,
  2595  				`		return errors.CompositeValidationError(res...`,
  2596  			},
  2597  		},
  2598  
  2599  		// load expectations for parameters in operation get_array_nested_parameters.go
  2600  		"getArrayNested": { // fixture index
  2601  			"serverParameter": { // executed template
  2602  				// expected code lines
  2603  				`func NewGetArrayNestedParams() GetArrayNestedParams {`,
  2604  				`	return GetArrayNestedParams{`,
  2605  				`type GetArrayNestedParams struct {`,
  2606  				"	HTTPRequest *http.Request `json:\"-\"`",
  2607  				`	ArrayOfarray [][]*models.ModelObject`,
  2608  				`func (o *GetArrayNestedParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2609  				`	o.HTTPRequest = r`,
  2610  				`	if runtime.HasBody(r) {`,
  2611  				`		defer r.Body.Close(`,
  2612  				`		var body [][]*models.ModelObject`,
  2613  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2614  				`			if err == io.EOF {`,
  2615  				`				res = append(res, errors.Required("arrayOfarray", "body")`,
  2616  				`			} else {`,
  2617  				`				res = append(res, errors.NewParseError("arrayOfarray", "body", "", err)`,
  2618  				`		} else {`,
  2619  				`			o.ArrayOfarray = body`,
  2620  				`			if err := o.validateArrayOfarrayBody(route.Formats); err != nil {`,
  2621  				`	} else {`,
  2622  				`		res = append(res, errors.Required("arrayOfarray", "body")`,
  2623  				`		return errors.CompositeValidationError(res...`,
  2624  				`func (o *GetArrayNestedParams) validateArrayOfarrayBody(formats strfmt.Registry) error {`,
  2625  				`	arrayOfarrayIC := o.ArrayOfarray`,
  2626  				`	var arrayOfarrayIR [][]*models.ModelObject`,
  2627  				`	for i, arrayOfarrayIV := range arrayOfarrayIC {`,
  2628  				`		arrayOfarrayIIC := arrayOfarrayIV`,
  2629  				`		if len(arrayOfarrayIIC) > 0 {`,
  2630  				`			var arrayOfarrayIIR []*models.ModelObject`,
  2631  				`			for ii, arrayOfarrayIIV := range arrayOfarrayIIC {`,
  2632  				`				if arrayOfarrayIIV == nil {`,
  2633  				`					if err := arrayOfarrayII.Validate(formats); err != nil {`,
  2634  				`						if ve, ok := err.(*errors.Validation); ok {`,
  2635  				`							return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "arrayOfarray", i), ii)`,
  2636  				`				arrayOfarrayIIR = append(arrayOfarrayIIR, arrayOfarrayII`,
  2637  				`			arrayOfarrayIR = append(arrayOfarrayIR, arrayOfarrayIIR`,
  2638  				`	o.ArrayOfarray = arrayOfarrayIR`,
  2639  			},
  2640  		},
  2641  
  2642  		// load expectations for parameters in operation get_map_array_parameters.go
  2643  		"getMapArray": { // fixture index
  2644  			"serverParameter": { // executed template
  2645  				// expected code lines
  2646  				`func NewGetMapArrayParams() GetMapArrayParams {`,
  2647  				`	return GetMapArrayParams{`,
  2648  				`type GetMapArrayParams struct {`,
  2649  				"	HTTPRequest *http.Request `json:\"-\"`",
  2650  				// maps are now simple types
  2651  				//`	MapOfArray models.GetMapArrayParamsBody`,
  2652  				`	MapOfArray map[string]models.ModelArray`,
  2653  				`func (o *GetMapArrayParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2654  				`	o.HTTPRequest = r`,
  2655  				`	if runtime.HasBody(r) {`,
  2656  				`		defer r.Body.Close(`,
  2657  				//`		var body models.GetMapArrayParamsBody`,
  2658  				`		var body map[string]models.ModelArray`,
  2659  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2660  				`			if err == io.EOF {`,
  2661  				`				res = append(res, errors.Required("mapOfArray", "body")`,
  2662  				`			} else {`,
  2663  				`				res = append(res, errors.NewParseError("mapOfArray", "body", "", err)`,
  2664  				`		} else {`,
  2665  				//`			if err := body.Validate(route.Formats); err != nil {`,
  2666  				`       	for k := range body {`,
  2667  				`       		if err := validate.Required(fmt.Sprintf("%s.%v", "mapOfArray", k), "body", body[k]); err != nil {`,
  2668  				`       		if val, ok := body[k]; ok {`,
  2669  				`       			if err := val.Validate(route.Formats); err != nil {`,
  2670  				`			if len(res) == 0 {`,
  2671  				`				o.MapOfArray = body`,
  2672  				`	} else {`,
  2673  				`		res = append(res, errors.Required("mapOfArray", "body")`,
  2674  				`		return errors.CompositeValidationError(res...`,
  2675  			},
  2676  		},
  2677  
  2678  		// load expectations for parameters in operation get_map_anon_array_with_nullable_parameters.go
  2679  		"getMapAnonArrayWithNullable": { // fixture index
  2680  			"serverParameter": { // executed template
  2681  				// expected code lines
  2682  				`func NewGetMapAnonArrayWithNullableParams() GetMapAnonArrayWithNullableParams {`,
  2683  				`	return GetMapAnonArrayWithNullableParams{`,
  2684  				`type GetMapAnonArrayWithNullableParams struct {`,
  2685  				"	HTTPRequest *http.Request `json:\"-\"`",
  2686  				`	MapOfAnonArrayWithNullable map[string][]*int64`,
  2687  				`func (o *GetMapAnonArrayWithNullableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2688  				`	o.HTTPRequest = r`,
  2689  				`	if runtime.HasBody(r) {`,
  2690  				`		defer r.Body.Close(`,
  2691  				`		var body map[string][]*int64`,
  2692  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2693  				`			if err == io.EOF {`,
  2694  				`				res = append(res, errors.Required("mapOfAnonArrayWithNullable", "body")`,
  2695  				`			} else {`,
  2696  				`				res = append(res, errors.NewParseError("mapOfAnonArrayWithNullable", "body", "", err)`,
  2697  				`		} else {`,
  2698  				`			o.MapOfAnonArrayWithNullable = body`,
  2699  				`			if err := o.validateMapOfAnonArrayWithNullableBody(route.Formats); err != nil {`,
  2700  				`	} else {`,
  2701  				`		res = append(res, errors.Required("mapOfAnonArrayWithNullable", "body")`,
  2702  				`		return errors.CompositeValidationError(res...`,
  2703  				`func (o *GetMapAnonArrayWithNullableParams) validateMapOfAnonArrayWithNullableBody(formats strfmt.Registry) error {`,
  2704  				`	mapOfAnonArrayWithNullableIC := o.MapOfAnonArrayWithNullable`,
  2705  				`	mapOfAnonArrayWithNullableIR := make(map[string][]*int64, len(mapOfAnonArrayWithNullableIC)`,
  2706  				`	for k, mapOfAnonArrayWithNullableIV := range mapOfAnonArrayWithNullableIC {`,
  2707  				`		mapOfAnonArrayWithNullableIIC := mapOfAnonArrayWithNullableIV`,
  2708  				`		var mapOfAnonArrayWithNullableIIR []*int64`,
  2709  				`		for ii, mapOfAnonArrayWithNullableIIV := range mapOfAnonArrayWithNullableIIC {`,
  2710  				`			mapOfAnonArrayWithNullableII := mapOfAnonArrayWithNullableIIV`,
  2711  				`			if err := validate.MinimumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfAnonArrayWithNullable", k), ii), "", int64(*mapOfAnonArrayWithNullableII), 0, false); err != nil {`,
  2712  				`			mapOfAnonArrayWithNullableIIR = append(mapOfAnonArrayWithNullableIIR, mapOfAnonArrayWithNullableII`,
  2713  				`		mapOfAnonArrayWithNullableIR[k] = mapOfAnonArrayWithNullableIIR`,
  2714  				`	o.MapOfAnonArrayWithNullable = mapOfAnonArrayWithNullableIR`,
  2715  			},
  2716  		},
  2717  
  2718  		// load expectations for parameters in operation get_map_of_anon_array_parameters.go
  2719  		"getMapOfAnonArray": { // fixture index
  2720  			"serverParameter": { // executed template
  2721  				// expected code lines
  2722  				`func NewGetMapOfAnonArrayParams() GetMapOfAnonArrayParams {`,
  2723  				`	return GetMapOfAnonArrayParams{`,
  2724  				`type GetMapOfAnonArrayParams struct {`,
  2725  				"	HTTPRequest *http.Request `json:\"-\"`",
  2726  				`	MapOfAnonArray map[string][]int64`,
  2727  				`func (o *GetMapOfAnonArrayParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2728  				`	o.HTTPRequest = r`,
  2729  				`	if runtime.HasBody(r) {`,
  2730  				`		defer r.Body.Close(`,
  2731  				`		var body map[string][]int64`,
  2732  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2733  				`			if err == io.EOF {`,
  2734  				`				res = append(res, errors.Required("mapOfAnonArray", "body")`,
  2735  				`			} else {`,
  2736  				`				res = append(res, errors.NewParseError("mapOfAnonArray", "body", "", err)`,
  2737  				`		} else {`,
  2738  				`			o.MapOfAnonArray = body`,
  2739  				`			if err := o.validateMapOfAnonArrayBody(route.Formats); err != nil {`,
  2740  				`	} else {`,
  2741  				`		res = append(res, errors.Required("mapOfAnonArray", "body")`,
  2742  				`		return errors.CompositeValidationError(res...`,
  2743  				`func (o *GetMapOfAnonArrayParams) validateMapOfAnonArrayBody(formats strfmt.Registry) error {`,
  2744  				`	mapOfAnonArrayIC := o.MapOfAnonArray`,
  2745  				`	mapOfAnonArrayIR := make(map[string][]int64, len(mapOfAnonArrayIC)`,
  2746  				`	for k, mapOfAnonArrayIV := range mapOfAnonArrayIC {`,
  2747  				`		mapOfAnonArrayIIC := mapOfAnonArrayIV`,
  2748  				`		var mapOfAnonArrayIIR []int64`,
  2749  				`		for ii, mapOfAnonArrayIIV := range mapOfAnonArrayIIC {`,
  2750  				`			mapOfAnonArrayII := mapOfAnonArrayIIV`,
  2751  				`			if err := validate.MaximumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfAnonArray", k), ii), "", int64(mapOfAnonArrayII), 100, false); err != nil {`,
  2752  				`			mapOfAnonArrayIIR = append(mapOfAnonArrayIIR, mapOfAnonArrayII`,
  2753  				`		mapOfAnonArrayIR[k] = mapOfAnonArrayIIR`,
  2754  				`	o.MapOfAnonArray = mapOfAnonArrayIR`,
  2755  			},
  2756  		},
  2757  
  2758  		// load expectations for parameters in operation get_map_of_anon_map_parameters.go
  2759  		"getMapOfAnonMap": { // fixture index
  2760  			"serverParameter": { // executed template
  2761  				// expected code lines
  2762  				`func NewGetMapOfAnonMapParams() GetMapOfAnonMapParams {`,
  2763  				`	return GetMapOfAnonMapParams{`,
  2764  				`type GetMapOfAnonMapParams struct {`,
  2765  				"	HTTPRequest *http.Request `json:\"-\"`",
  2766  				`	MapOfAnonMap map[string]map[string][]int64`,
  2767  				`func (o *GetMapOfAnonMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2768  				`	o.HTTPRequest = r`,
  2769  				`	if runtime.HasBody(r) {`,
  2770  				`		defer r.Body.Close(`,
  2771  				`		var body map[string]map[string][]int64`,
  2772  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2773  				`			if err == io.EOF {`,
  2774  				`				res = append(res, errors.Required("mapOfAnonMap", "body")`,
  2775  				`			} else {`,
  2776  				`				res = append(res, errors.NewParseError("mapOfAnonMap", "body", "", err)`,
  2777  				`		} else {`,
  2778  				`			o.MapOfAnonMap = body`,
  2779  				`			if err := o.validateMapOfAnonMapBody(route.Formats); err != nil {`,
  2780  				`	} else {`,
  2781  				`		res = append(res, errors.Required("mapOfAnonMap", "body")`,
  2782  				`		return errors.CompositeValidationError(res...`,
  2783  				`func (o *GetMapOfAnonMapParams) validateMapOfAnonMapBody(formats strfmt.Registry) error {`,
  2784  				`	mapOfAnonMapIC := o.MapOfAnonMap`,
  2785  				`	mapOfAnonMapIR := make(map[string]map[string][]int64, len(mapOfAnonMapIC)`,
  2786  				`	for k, mapOfAnonMapIV := range mapOfAnonMapIC {`,
  2787  				`		mapOfAnonMapIIC := mapOfAnonMapIV`,
  2788  				`		mapOfAnonMapIIR := make(map[string][]int64, len(mapOfAnonMapIIC)`,
  2789  				`		for kk, mapOfAnonMapIIV := range mapOfAnonMapIIC {`,
  2790  				`			mapOfAnonMapIIIC := mapOfAnonMapIIV`,
  2791  				`			var mapOfAnonMapIIIR []int64`,
  2792  				`			for iii, mapOfAnonMapIIIV := range mapOfAnonMapIIIC {`,
  2793  				`				mapOfAnonMapIII := mapOfAnonMapIIIV`,
  2794  				`				if err := validate.MaximumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfAnonMap", k), kk), iii), "", int64(mapOfAnonMapIII), 100, false); err != nil {`,
  2795  				`				mapOfAnonMapIIIR = append(mapOfAnonMapIIIR, mapOfAnonMapIII`,
  2796  				`			mapOfAnonMapIIR[kk] = mapOfAnonMapIIIR`,
  2797  				`		mapOfAnonMapIR[k] = mapOfAnonMapIIR`,
  2798  				`	o.MapOfAnonMap = mapOfAnonMapIR`,
  2799  			},
  2800  		},
  2801  
  2802  		// load expectations for parameters in operation get_map_anon_array_parameters.go
  2803  		"getMapAnonArray": { // fixture index
  2804  			"serverParameter": { // executed template
  2805  				// expected code lines
  2806  				`func NewGetMapAnonArrayParams() GetMapAnonArrayParams {`,
  2807  				`	return GetMapAnonArrayParams{`,
  2808  				`type GetMapAnonArrayParams struct {`,
  2809  				"	HTTPRequest *http.Request `json:\"-\"`",
  2810  				`	MapOfAnonArray map[string][]int64`,
  2811  				`func (o *GetMapAnonArrayParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2812  				`	o.HTTPRequest = r`,
  2813  				`	if runtime.HasBody(r) {`,
  2814  				`		defer r.Body.Close(`,
  2815  				`		var body map[string][]int64`,
  2816  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2817  				`			if err == io.EOF {`,
  2818  				`				res = append(res, errors.Required("mapOfAnonArray", "body")`,
  2819  				`			} else {`,
  2820  				`				res = append(res, errors.NewParseError("mapOfAnonArray", "body", "", err)`,
  2821  				`		} else {`,
  2822  				`			o.MapOfAnonArray = body`,
  2823  				`			if err := o.validateMapOfAnonArrayBody(route.Formats); err != nil {`,
  2824  				`	} else {`,
  2825  				`		res = append(res, errors.Required("mapOfAnonArray", "body")`,
  2826  				`		return errors.CompositeValidationError(res...`,
  2827  				`func (o *GetMapAnonArrayParams) validateMapOfAnonArrayBody(formats strfmt.Registry) error {`,
  2828  				`	mapOfAnonArrayIC := o.MapOfAnonArray`,
  2829  				`	mapOfAnonArrayIR := make(map[string][]int64, len(mapOfAnonArrayIC)`,
  2830  				`	for k, mapOfAnonArrayIV := range mapOfAnonArrayIC {`,
  2831  				`		mapOfAnonArrayIIC := mapOfAnonArrayIV`,
  2832  				`		var mapOfAnonArrayIIR []int64`,
  2833  				`		for ii, mapOfAnonArrayIIV := range mapOfAnonArrayIIC {`,
  2834  				`			mapOfAnonArrayII := mapOfAnonArrayIIV`,
  2835  				`			if err := validate.MinimumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfAnonArray", k), ii), "", int64(mapOfAnonArrayII), 10, false); err != nil {`,
  2836  				`			mapOfAnonArrayIIR = append(mapOfAnonArrayIIR, mapOfAnonArrayII`,
  2837  				`		mapOfAnonArrayIR[k] = mapOfAnonArrayIIR`,
  2838  				`	o.MapOfAnonArray = mapOfAnonArrayIR`,
  2839  			},
  2840  		},
  2841  
  2842  		// load expectations for parameters in operation get_map_of_primitive_parameters.go
  2843  		"getMapOfPrimitive": { // fixture index
  2844  			"serverParameter": { // executed template
  2845  				// expected code lines
  2846  				`func NewGetMapOfPrimitiveParams() GetMapOfPrimitiveParams {`,
  2847  				`	return GetMapOfPrimitiveParams{`,
  2848  				`type GetMapOfPrimitiveParams struct {`,
  2849  				"	HTTPRequest *http.Request `json:\"-\"`",
  2850  				`	MapOfPrimitive map[string]int64`,
  2851  				`func (o *GetMapOfPrimitiveParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2852  				`	o.HTTPRequest = r`,
  2853  				`	if runtime.HasBody(r) {`,
  2854  				`		defer r.Body.Close(`,
  2855  				`		var body map[string]int64`,
  2856  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2857  				`			if err == io.EOF {`,
  2858  				`				res = append(res, errors.Required("mapOfPrimitive", "body")`,
  2859  				`			} else {`,
  2860  				`				res = append(res, errors.NewParseError("mapOfPrimitive", "body", "", err)`,
  2861  				`		} else {`,
  2862  				`			o.MapOfPrimitive = body`,
  2863  				`			if err := o.validateMapOfPrimitiveBody(route.Formats); err != nil {`,
  2864  				`	} else {`,
  2865  				`		res = append(res, errors.Required("mapOfPrimitive", "body")`,
  2866  				`		return errors.CompositeValidationError(res...`,
  2867  				`func (o *GetMapOfPrimitiveParams) validateMapOfPrimitiveBody(formats strfmt.Registry) error {`,
  2868  				`	mapOfPrimitiveIC := o.MapOfPrimitive`,
  2869  				`	mapOfPrimitiveIR := make(map[string]int64, len(mapOfPrimitiveIC)`,
  2870  				`	for k, mapOfPrimitiveIV := range mapOfPrimitiveIC {`,
  2871  				`		mapOfPrimitiveI := mapOfPrimitiveIV`,
  2872  				`		if err := validate.MaximumInt(fmt.Sprintf("%s.%v", "mapOfPrimitive", k), "body", int64(mapOfPrimitiveI), 100, false); err != nil {`,
  2873  				`		mapOfPrimitiveIR[k] = mapOfPrimitiveI`,
  2874  				`	o.MapOfPrimitive = mapOfPrimitiveIR`,
  2875  			},
  2876  		},
  2877  
  2878  		// load expectations for parameters in operation get_array_parameters.go
  2879  		"getArray": { // fixture index
  2880  			"serverParameter": { // executed template
  2881  				// expected code lines
  2882  				`func NewGetArrayParams() GetArrayParams {`,
  2883  				`	return GetArrayParams{`,
  2884  				`type GetArrayParams struct {`,
  2885  				"	HTTPRequest *http.Request `json:\"-\"`",
  2886  				`	ArrayOfObject []*models.ModelObject`,
  2887  				`func (o *GetArrayParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2888  				`	o.HTTPRequest = r`,
  2889  				`	if runtime.HasBody(r) {`,
  2890  				`		defer r.Body.Close(`,
  2891  				`		var body []*models.ModelObject`,
  2892  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2893  				`			if err == io.EOF {`,
  2894  				`				res = append(res, errors.Required("arrayOfObject", "body")`,
  2895  				`			} else {`,
  2896  				`				res = append(res, errors.NewParseError("arrayOfObject", "body", "", err)`,
  2897  				`		} else {`,
  2898  				`			for i := range body {`,
  2899  				`				if body[i] == nil {`,
  2900  				`					if err := body[i].Validate(route.Formats); err != nil {`,
  2901  				`						break`,
  2902  				`			if len(res) == 0 {`,
  2903  				`				o.ArrayOfObject = body`,
  2904  				`	} else {`,
  2905  				`		res = append(res, errors.Required("arrayOfObject", "body")`,
  2906  				`		return errors.CompositeValidationError(res...`,
  2907  			},
  2908  		},
  2909  
  2910  		// load expectations for parameters in operation get_map_object_parameters.go
  2911  		"getMapObject": { // fixture index
  2912  			"serverParameter": { // executed template
  2913  				// expected code lines
  2914  				`func NewGetMapObjectParams() GetMapObjectParams {`,
  2915  				`	return GetMapObjectParams{`,
  2916  				`type GetMapObjectParams struct {`,
  2917  				"	HTTPRequest *http.Request `json:\"-\"`",
  2918  				//`	MapOfObject models.GetMapObjectParamsBody`,
  2919  				// maps are now simple types
  2920  				`	MapOfObject map[string]models.ModelObject`,
  2921  				`func (o *GetMapObjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2922  				`	o.HTTPRequest = r`,
  2923  				`	if runtime.HasBody(r) {`,
  2924  				`		defer r.Body.Close(`,
  2925  				//`		var body models.GetMapObjectParamsBody`,
  2926  				`		var body map[string]models.ModelObject`,
  2927  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2928  				`			if err == io.EOF {`,
  2929  				`				res = append(res, errors.Required("mapOfObject", "body")`,
  2930  				`			} else {`,
  2931  				`				res = append(res, errors.NewParseError("mapOfObject", "body", "", err)`,
  2932  				`		} else {`,
  2933  				//`			if err := body.Validate(route.Formats); err != nil {`,
  2934  				`       	for k := range body {`,
  2935  				`       		if err := validate.Required(fmt.Sprintf("%s.%v", "mapOfObject", k), "body", body[k]); err != nil {`,
  2936  				`       		if val, ok := body[k]; ok {`,
  2937  				`       			if err := val.Validate(route.Formats); err != nil {`,
  2938  				`			if len(res) == 0 {`,
  2939  				`				o.MapOfObject = body`,
  2940  				`	} else {`,
  2941  				`		res = append(res, errors.Required("mapOfObject", "body")`,
  2942  				`		return errors.CompositeValidationError(res...`,
  2943  			},
  2944  		},
  2945  
  2946  		// load expectations for parameters in operation get_map_of_map_parameters.go
  2947  		"getMapOfMap": { // fixture index
  2948  			"serverParameter": { // executed template
  2949  				// expected code lines
  2950  				`func NewGetMapOfMapParams() GetMapOfMapParams {`,
  2951  				`	return GetMapOfMapParams{`,
  2952  				`type GetMapOfMapParams struct {`,
  2953  				"	HTTPRequest *http.Request `json:\"-\"`",
  2954  				`	MapOfMap map[string]map[string]models.ModelArrayWithMax`,
  2955  				`func (o *GetMapOfMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  2956  				`	o.HTTPRequest = r`,
  2957  				`	if runtime.HasBody(r) {`,
  2958  				`		defer r.Body.Close(`,
  2959  				`		var body map[string]map[string]models.ModelArrayWithMax`,
  2960  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  2961  				`			if err == io.EOF {`,
  2962  				`				res = append(res, errors.Required("mapOfMap", "body")`,
  2963  				`			} else {`,
  2964  				`				res = append(res, errors.NewParseError("mapOfMap", "body", "", err)`,
  2965  				`		} else {`,
  2966  				`			o.MapOfMap = body`,
  2967  				`			if err := o.validateMapOfMapBody(route.Formats); err != nil {`,
  2968  				`	} else {`,
  2969  				`		res = append(res, errors.Required("mapOfMap", "body")`,
  2970  				`		return errors.CompositeValidationError(res...`,
  2971  				`func (o *GetMapOfMapParams) validateMapOfMapBody(formats strfmt.Registry) error {`,
  2972  				`	mapOfMapIC := o.MapOfMap`,
  2973  				`	mapOfMapIR := make(map[string]map[string]models.ModelArrayWithMax, len(mapOfMapIC)`,
  2974  				`	for k, mapOfMapIV := range mapOfMapIC {`,
  2975  				`		mapOfMapIIC := mapOfMapIV`,
  2976  				`		mapOfMapIIR := make(map[string]models.ModelArrayWithMax, len(mapOfMapIIC)`,
  2977  				`		for kk, mapOfMapIIV := range mapOfMapIIC {`,
  2978  				`			mapOfMapII := mapOfMapIIV`,
  2979  				`			if err := mapOfMapII.Validate(formats); err != nil {`,
  2980  				`				if ve, ok := err.(*errors.Validation); ok {`,
  2981  				`					return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfMap", k), kk)`,
  2982  				`			mapOfMapIIR[kk] = mapOfMapII`,
  2983  				`		mapOfMapIR[k] = mapOfMapIIR`,
  2984  				`	o.MapOfMap = mapOfMapIR`,
  2985  			},
  2986  		},
  2987  	}
  2988  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1536", "fixture-1536-3.yaml"), false, false)
  2989  }
  2990  
  2991  func TestGenParameter_Issue1536_MapsWithExpand(t *testing.T) {
  2992  	log.SetOutput(ioutil.Discard)
  2993  	defer func() {
  2994  		log.SetOutput(os.Stdout)
  2995  	}()
  2996  
  2997  	fixtureConfig := map[string]map[string][]string{
  2998  		// load expectations for parameters in operation get_map_of_array_of_map_parameters.go
  2999  		"getMapOfArrayOfMap": { // fixture index
  3000  			"serverParameter": { // executed template
  3001  				// expected code lines
  3002  				`func NewGetMapOfArrayOfMapParams() GetMapOfArrayOfMapParams {`,
  3003  				`	return GetMapOfArrayOfMapParams{`,
  3004  				`type GetMapOfArrayOfMapParams struct {`,
  3005  				"	HTTPRequest *http.Request `json:\"-\"`",
  3006  				`	MapOfArrayOfMap map[string][]map[string]int64`,
  3007  				`func (o *GetMapOfArrayOfMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3008  				`	o.HTTPRequest = r`,
  3009  				`	if runtime.HasBody(r) {`,
  3010  				`		defer r.Body.Close(`,
  3011  				`		var body map[string][]map[string]int64`,
  3012  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3013  				`			if err == io.EOF {`,
  3014  				`				res = append(res, errors.Required("mapOfArrayOfMap", "body")`,
  3015  				`			} else {`,
  3016  				`				res = append(res, errors.NewParseError("mapOfArrayOfMap", "body", "", err)`,
  3017  				`		} else {`,
  3018  				`			o.MapOfArrayOfMap = body`,
  3019  				`			if err := o.validateMapOfArrayOfMapBody(route.Formats); err != nil {`,
  3020  				`	} else {`,
  3021  				`		res = append(res, errors.Required("mapOfArrayOfMap", "body")`,
  3022  				`		return errors.CompositeValidationError(res...`,
  3023  				`func (o *GetMapOfArrayOfMapParams) validateMapOfArrayOfMapBody(formats strfmt.Registry) error {`,
  3024  				`	mapOfArrayOfMapIC := o.MapOfArrayOfMap`,
  3025  				`	mapOfArrayOfMapIR := make(map[string][]map[string]int64, len(mapOfArrayOfMapIC)`,
  3026  				`	for k, mapOfArrayOfMapIV := range mapOfArrayOfMapIC {`,
  3027  				`		mapOfArrayOfMapIIC := mapOfArrayOfMapIV`,
  3028  				`		mapOfArrayOfMapISize := int64(len(mapOfArrayOfMapIIC)`,
  3029  				`		if err := validate.MaxItems(fmt.Sprintf("%s.%v", "mapOfArrayOfMap", k), "body", mapOfArrayOfMapISize, 10); err != nil {`,
  3030  				`		var mapOfArrayOfMapIIR []map[string]int64`,
  3031  				`		for _, mapOfArrayOfMapIIV := range mapOfArrayOfMapIIC {`,
  3032  				`			mapOfArrayOfMapIIIC := mapOfArrayOfMapIIV`,
  3033  				`			mapOfArrayOfMapIIIR := make(map[string]int64, len(mapOfArrayOfMapIIIC)`,
  3034  				`			for kkk, mapOfArrayOfMapIIIV := range mapOfArrayOfMapIIIC {`,
  3035  				`				mapOfArrayOfMapIII := mapOfArrayOfMapIIIV`,
  3036  				`				mapOfArrayOfMapIIIR[kkk] = mapOfArrayOfMapIII`,
  3037  				`			mapOfArrayOfMapIIR = append(mapOfArrayOfMapIIR, mapOfArrayOfMapIIIR`,
  3038  				`		mapOfArrayOfMapIR[k] = mapOfArrayOfMapIIR`,
  3039  				`	o.MapOfArrayOfMap = mapOfArrayOfMapIR`,
  3040  			},
  3041  		},
  3042  
  3043  		// load expectations for parameters in operation get_map_of_array_of_nullable_map_parameters.go
  3044  		"getMapOfArrayOfNullableMap": { // fixture index
  3045  			"serverParameter": { // executed template
  3046  				// expected code lines
  3047  				`func NewGetMapOfArrayOfNullableMapParams() GetMapOfArrayOfNullableMapParams {`,
  3048  				`	return GetMapOfArrayOfNullableMapParams{`,
  3049  				`type GetMapOfArrayOfNullableMapParams struct {`,
  3050  				"	HTTPRequest *http.Request `json:\"-\"`",
  3051  				`	MapOfArrayOfNullableMap map[string][]GetMapOfArrayOfNullableMapParamsBodyItems0`,
  3052  				`func (o *GetMapOfArrayOfNullableMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3053  				`	o.HTTPRequest = r`,
  3054  				`	if runtime.HasBody(r) {`,
  3055  				`		defer r.Body.Close(`,
  3056  				`		var body map[string][]GetMapOfArrayOfNullableMapParamsBodyItems0`,
  3057  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3058  				`			if err == io.EOF {`,
  3059  				`				res = append(res, errors.Required("mapOfArrayOfNullableMap", "body")`,
  3060  				`			} else {`,
  3061  				`				res = append(res, errors.NewParseError("mapOfArrayOfNullableMap", "body", "", err)`,
  3062  				`		} else {`,
  3063  				`			o.MapOfArrayOfNullableMap = body`,
  3064  				`			if err := o.validateMapOfArrayOfNullableMapBody(route.Formats); err != nil {`,
  3065  				`	} else {`,
  3066  				`		res = append(res, errors.Required("mapOfArrayOfNullableMap", "body")`,
  3067  				`		return errors.CompositeValidationError(res...`,
  3068  				`func (o *GetMapOfArrayOfNullableMapParams) validateMapOfArrayOfNullableMapBody(formats strfmt.Registry) error {`,
  3069  				`	mapOfArrayOfNullableMapIC := o.MapOfArrayOfNullableMap`,
  3070  				`	mapOfArrayOfNullableMapIR := make(map[string][]GetMapOfArrayOfNullableMapParamsBodyItems0, len(mapOfArrayOfNullableMapIC)`,
  3071  				`	for k, mapOfArrayOfNullableMapIV := range mapOfArrayOfNullableMapIC {`,
  3072  				`		mapOfArrayOfNullableMapIIC := mapOfArrayOfNullableMapIV`,
  3073  				`		mapOfArrayOfNullableMapISize := int64(len(mapOfArrayOfNullableMapIIC)`,
  3074  				`		if err := validate.MaxItems(fmt.Sprintf("%s.%v", "mapOfArrayOfNullableMap", k), "body", mapOfArrayOfNullableMapISize, 10); err != nil {`,
  3075  				`		var mapOfArrayOfNullableMapIIR []GetMapOfArrayOfNullableMapParamsBodyItems0`,
  3076  				`		for ii, mapOfArrayOfNullableMapIIV := range mapOfArrayOfNullableMapIIC {`,
  3077  				`			mapOfArrayOfNullableMapII := mapOfArrayOfNullableMapIIV`,
  3078  				`			if err := mapOfArrayOfNullableMapII.Validate(formats); err != nil {`,
  3079  				`				if ve, ok := err.(*errors.Validation); ok {`,
  3080  				`					return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfArrayOfNullableMap", k), ii)`,
  3081  				`			mapOfArrayOfNullableMapIIR = append(mapOfArrayOfNullableMapIIR, mapOfArrayOfNullableMapII`,
  3082  				`		mapOfArrayOfNullableMapIR[k] = mapOfArrayOfNullableMapIIR`,
  3083  				`	o.MapOfArrayOfNullableMap = mapOfArrayOfNullableMapIR`,
  3084  			},
  3085  		},
  3086  
  3087  		// load expectations for parameters in operation get_map_array_of_array_parameters.go
  3088  		"getMapArrayOfArray": { // fixture index
  3089  			"serverParameter": { // executed template
  3090  				// expected code lines
  3091  				`func NewGetMapArrayOfArrayParams() GetMapArrayOfArrayParams {`,
  3092  				`	return GetMapArrayOfArrayParams{`,
  3093  				`type GetMapArrayOfArrayParams struct {`,
  3094  				"	HTTPRequest *http.Request `json:\"-\"`",
  3095  				`	MapOfArrayOfArray map[string][][]GetMapArrayOfArrayParamsBodyItems0`,
  3096  				`func (o *GetMapArrayOfArrayParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3097  				`	o.HTTPRequest = r`,
  3098  				`	if runtime.HasBody(r) {`,
  3099  				`		defer r.Body.Close(`,
  3100  				`		var body map[string][][]GetMapArrayOfArrayParamsBodyItems0`,
  3101  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3102  				`			if err == io.EOF {`,
  3103  				`				res = append(res, errors.Required("mapOfArrayOfArray", "body")`,
  3104  				`			} else {`,
  3105  				`				res = append(res, errors.NewParseError("mapOfArrayOfArray", "body", "", err)`,
  3106  				`		} else {`,
  3107  				`			o.MapOfArrayOfArray = body`,
  3108  				`			if err := o.validateMapOfArrayOfArrayBody(route.Formats); err != nil {`,
  3109  				`	} else {`,
  3110  				`		res = append(res, errors.Required("mapOfArrayOfArray", "body")`,
  3111  				`		return errors.CompositeValidationError(res...`,
  3112  				`func (o *GetMapArrayOfArrayParams) validateMapOfArrayOfArrayBody(formats strfmt.Registry) error {`,
  3113  				`	mapOfArrayOfArrayIC := o.MapOfArrayOfArray`,
  3114  				`	mapOfArrayOfArrayIR := make(map[string][][]GetMapArrayOfArrayParamsBodyItems0, len(mapOfArrayOfArrayIC)`,
  3115  				`	for k, mapOfArrayOfArrayIV := range mapOfArrayOfArrayIC {`,
  3116  				`		mapOfArrayOfArrayIIC := mapOfArrayOfArrayIV`,
  3117  				`		mapOfArrayOfArrayISize := int64(len(mapOfArrayOfArrayIIC)`,
  3118  				`		if err := validate.MaxItems(fmt.Sprintf("%s.%v", "mapOfArrayOfArray", k), "body", mapOfArrayOfArrayISize, 10); err != nil {`,
  3119  				`		var mapOfArrayOfArrayIIR [][]GetMapArrayOfArrayParamsBodyItems0`,
  3120  				`		for ii, mapOfArrayOfArrayIIV := range mapOfArrayOfArrayIIC {`,
  3121  				`			mapOfArrayOfArrayIIIC := mapOfArrayOfArrayIIV`,
  3122  				`			if len(mapOfArrayOfArrayIIIC) > 0 {`,
  3123  				`				var mapOfArrayOfArrayIIIR []GetMapArrayOfArrayParamsBodyItems0`,
  3124  				`				for iii, mapOfArrayOfArrayIIIV := range mapOfArrayOfArrayIIIC {`,
  3125  				`					mapOfArrayOfArrayIII := mapOfArrayOfArrayIIIV`,
  3126  				`					if err := mapOfArrayOfArrayIII.Validate(formats); err != nil {`,
  3127  				`						if ve, ok := err.(*errors.Validation); ok {`,
  3128  				`							return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfArrayOfArray", k), ii), iii)`,
  3129  				`					mapOfArrayOfArrayIIIR = append(mapOfArrayOfArrayIIIR, mapOfArrayOfArrayIII`,
  3130  				`				mapOfArrayOfArrayIIR = append(mapOfArrayOfArrayIIR, mapOfArrayOfArrayIIIR`,
  3131  				`		mapOfArrayOfArrayIR[k] = mapOfArrayOfArrayIIR`,
  3132  				`	o.MapOfArrayOfArray = mapOfArrayOfArrayIR`,
  3133  			},
  3134  		},
  3135  
  3136  		// load expectations for parameters in operation get_map_anon_array_with_nested_nullable_parameters.go
  3137  		"getMapAnonArrayWithNestedNullable": { // fixture index
  3138  			"serverParameter": { // executed template
  3139  				// expected code lines
  3140  				`func NewGetMapAnonArrayWithNestedNullableParams() GetMapAnonArrayWithNestedNullableParams {`,
  3141  				`	return GetMapAnonArrayWithNestedNullableParams{`,
  3142  				`type GetMapAnonArrayWithNestedNullableParams struct {`,
  3143  				"	HTTPRequest *http.Request `json:\"-\"`",
  3144  				`	MapOfAnonArrayWithNestedNullable map[string][][]*int64`,
  3145  				`func (o *GetMapAnonArrayWithNestedNullableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3146  				`	o.HTTPRequest = r`,
  3147  				`	if runtime.HasBody(r) {`,
  3148  				`		defer r.Body.Close(`,
  3149  				`		var body map[string][][]*int64`,
  3150  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3151  				`			if err == io.EOF {`,
  3152  				`				res = append(res, errors.Required("mapOfAnonArrayWithNestedNullable", "body")`,
  3153  				`			} else {`,
  3154  				`				res = append(res, errors.NewParseError("mapOfAnonArrayWithNestedNullable", "body", "", err)`,
  3155  				`		} else {`,
  3156  				`			o.MapOfAnonArrayWithNestedNullable = body`,
  3157  				`			if err := o.validateMapOfAnonArrayWithNestedNullableBody(route.Formats); err != nil {`,
  3158  				`	} else {`,
  3159  				`		res = append(res, errors.Required("mapOfAnonArrayWithNestedNullable", "body")`,
  3160  				`		return errors.CompositeValidationError(res...`,
  3161  				`func (o *GetMapAnonArrayWithNestedNullableParams) validateMapOfAnonArrayWithNestedNullableBody(formats strfmt.Registry) error {`,
  3162  				`	mapOfAnonArrayWithNestedNullableIC := o.MapOfAnonArrayWithNestedNullable`,
  3163  				`	mapOfAnonArrayWithNestedNullableIR := make(map[string][][]*int64, len(mapOfAnonArrayWithNestedNullableIC)`,
  3164  				`	for k, mapOfAnonArrayWithNestedNullableIV := range mapOfAnonArrayWithNestedNullableIC {`,
  3165  				`		mapOfAnonArrayWithNestedNullableIIC := mapOfAnonArrayWithNestedNullableIV`,
  3166  				`		var mapOfAnonArrayWithNestedNullableIIR [][]*int64`,
  3167  				`		for ii, mapOfAnonArrayWithNestedNullableIIV := range mapOfAnonArrayWithNestedNullableIIC {`,
  3168  				`			mapOfAnonArrayWithNestedNullableIIIC := mapOfAnonArrayWithNestedNullableIIV`,
  3169  				`			if len(mapOfAnonArrayWithNestedNullableIIIC) > 0 {`,
  3170  				`				var mapOfAnonArrayWithNestedNullableIIIR []*int64`,
  3171  				`				for iii, mapOfAnonArrayWithNestedNullableIIIV := range mapOfAnonArrayWithNestedNullableIIIC {`,
  3172  				`					mapOfAnonArrayWithNestedNullableIII := mapOfAnonArrayWithNestedNullableIIIV`,
  3173  				`					if err := validate.MinimumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "mapOfAnonArrayWithNestedNullable", k), ii), iii), "", int64(*mapOfAnonArrayWithNestedNullableIII), 0, false); err != nil {`,
  3174  				`					mapOfAnonArrayWithNestedNullableIIIR = append(mapOfAnonArrayWithNestedNullableIIIR, mapOfAnonArrayWithNestedNullableIII`,
  3175  				`				mapOfAnonArrayWithNestedNullableIIR = append(mapOfAnonArrayWithNestedNullableIIR, mapOfAnonArrayWithNestedNullableIIIR`,
  3176  				`		mapOfAnonArrayWithNestedNullableIR[k] = mapOfAnonArrayWithNestedNullableIIR`,
  3177  				`	o.MapOfAnonArrayWithNestedNullable = mapOfAnonArrayWithNestedNullableIR`,
  3178  			},
  3179  		},
  3180  
  3181  		// load expectations for parameters in operation get_map_of_model_map_parameters.go
  3182  		"getMapOfModelMap": { // fixture index
  3183  			"serverParameter": { // executed template
  3184  				// expected code lines
  3185  				`func NewGetMapOfModelMapParams() GetMapOfModelMapParams {`,
  3186  				`	return GetMapOfModelMapParams{`,
  3187  				`type GetMapOfModelMapParams struct {`,
  3188  				"	HTTPRequest *http.Request `json:\"-\"`",
  3189  				`	MapOfModelMap map[string]map[string]int64`,
  3190  				`func (o *GetMapOfModelMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3191  				`	o.HTTPRequest = r`,
  3192  				`	if runtime.HasBody(r) {`,
  3193  				`		defer r.Body.Close(`,
  3194  				`		var body map[string]map[string]int64`,
  3195  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3196  				`			if err == io.EOF {`,
  3197  				`				res = append(res, errors.Required("mapOfModelMap", "body")`,
  3198  				`			} else {`,
  3199  				`				res = append(res, errors.NewParseError("mapOfModelMap", "body", "", err)`,
  3200  				`		} else {`,
  3201  				`			o.MapOfModelMap = body`,
  3202  				`	} else {`,
  3203  				`		res = append(res, errors.Required("mapOfModelMap", "body")`,
  3204  				`		return errors.CompositeValidationError(res...`,
  3205  			},
  3206  		},
  3207  
  3208  		// load expectations for parameters in operation get_map_of_model_map_nullable_parameters.go
  3209  		"getMapOfModelMapNullable": { // fixture index
  3210  			"serverParameter": { // executed template
  3211  				// expected code lines
  3212  				`func NewGetMapOfModelMapNullableParams() GetMapOfModelMapNullableParams {`,
  3213  				`	return GetMapOfModelMapNullableParams{`,
  3214  				`type GetMapOfModelMapNullableParams struct {`,
  3215  				"	HTTPRequest *http.Request `json:\"-\"`",
  3216  				`	MapOfModelMapNullable map[string]map[string]*int64`,
  3217  				`func (o *GetMapOfModelMapNullableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3218  				`	o.HTTPRequest = r`,
  3219  				`	if runtime.HasBody(r) {`,
  3220  				`		defer r.Body.Close(`,
  3221  				`		var body map[string]map[string]*int64`,
  3222  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3223  				`			if err == io.EOF {`,
  3224  				`				res = append(res, errors.Required("mapOfModelMapNullable", "body")`,
  3225  				`			} else {`,
  3226  				`				res = append(res, errors.NewParseError("mapOfModelMapNullable", "body", "", err)`,
  3227  				`		} else {`,
  3228  				`			o.MapOfModelMapNullable = body`,
  3229  				`	} else {`,
  3230  				`		res = append(res, errors.Required("mapOfModelMapNullable", "body")`,
  3231  				`		return errors.CompositeValidationError(res...`,
  3232  			},
  3233  		},
  3234  	}
  3235  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1536", "fixture-1536-3.yaml"), true, true)
  3236  }
  3237  func TestGenParameter_Issue1536_MoreMaps(t *testing.T) {
  3238  	log.SetOutput(ioutil.Discard)
  3239  	defer func() {
  3240  		log.SetOutput(os.Stdout)
  3241  	}()
  3242  
  3243  	// testing fixture-1536-4.yaml with flatten
  3244  	// param body with maps
  3245  
  3246  	fixtureConfig := map[string]map[string][]string{
  3247  
  3248  		// load expectations for parameters in operation get_nested_map04_parameters.go
  3249  		"getNestedMap04": { // fixture index
  3250  			"serverParameter": { // executed template
  3251  				// expected code lines
  3252  				`func NewGetNestedMap04Params() GetNestedMap04Params {`,
  3253  				`	return GetNestedMap04Params{`,
  3254  				`type GetNestedMap04Params struct {`,
  3255  				"	HTTPRequest *http.Request `json:\"-\"`",
  3256  				`	NestedMap04 map[string]map[string]map[string]*bool`,
  3257  				`func (o *GetNestedMap04Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3258  				`	o.HTTPRequest = r`,
  3259  				`	if runtime.HasBody(r) {`,
  3260  				`		defer r.Body.Close(`,
  3261  				`		var body map[string]map[string]map[string]*bool`,
  3262  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3263  				`			if err == io.EOF {`,
  3264  				`				res = append(res, errors.Required("nestedMap04", "body")`,
  3265  				`			} else {`,
  3266  				`				res = append(res, errors.NewParseError("nestedMap04", "body", "", err)`,
  3267  				`		} else {`,
  3268  				`			o.NestedMap04 = body`,
  3269  				`	} else {`,
  3270  				`		res = append(res, errors.Required("nestedMap04", "body")`,
  3271  				`		return errors.CompositeValidationError(res...`,
  3272  			},
  3273  		},
  3274  
  3275  		// load expectations for parameters in operation get_nested_slice_and_map01_parameters.go
  3276  		"getNestedSliceAndMap01": { // fixture index
  3277  			"serverParameter": { // executed template
  3278  				// expected code lines
  3279  				`func NewGetNestedSliceAndMap01Params() GetNestedSliceAndMap01Params {`,
  3280  				`	return GetNestedSliceAndMap01Params{`,
  3281  				`type GetNestedSliceAndMap01Params struct {`,
  3282  				"	HTTPRequest *http.Request `json:\"-\"`",
  3283  				`	NestedSliceAndMap01 []map[string][]map[string]strfmt.Date`,
  3284  				`func (o *GetNestedSliceAndMap01Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3285  				`	o.HTTPRequest = r`,
  3286  				`	if runtime.HasBody(r) {`,
  3287  				`		defer r.Body.Close(`,
  3288  				`		var body []map[string][]map[string]strfmt.Date`,
  3289  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3290  				`			if err == io.EOF {`,
  3291  				`				res = append(res, errors.Required("nestedSliceAndMap01", "body")`,
  3292  				`			} else {`,
  3293  				`				res = append(res, errors.NewParseError("nestedSliceAndMap01", "body", "", err)`,
  3294  				`		} else {`,
  3295  				`			o.NestedSliceAndMap01 = body`,
  3296  				`			if err := o.validateNestedSliceAndMap01Body(route.Formats); err != nil {`,
  3297  				`	} else {`,
  3298  				`		res = append(res, errors.Required("nestedSliceAndMap01", "body")`,
  3299  				`		return errors.CompositeValidationError(res...`,
  3300  				`func (o *GetNestedSliceAndMap01Params) validateNestedSliceAndMap01Body(formats strfmt.Registry) error {`,
  3301  				`	if err := validate.UniqueItems("nestedSliceAndMap01", "body", o.NestedSliceAndMap01); err != nil {`,
  3302  				`	nestedSliceAndMap01IC := o.NestedSliceAndMap01`,
  3303  				`	var nestedSliceAndMap01IR []map[string][]map[string]strfmt.Date`,
  3304  				`	for i, nestedSliceAndMap01IV := range nestedSliceAndMap01IC {`,
  3305  				`		nestedSliceAndMap01IIC := nestedSliceAndMap01IV`,
  3306  				`		nestedSliceAndMap01IIR := make(map[string][]map[string]strfmt.Date, len(nestedSliceAndMap01IIC)`,
  3307  				`		for kk, nestedSliceAndMap01IIV := range nestedSliceAndMap01IIC {`,
  3308  				`			nestedSliceAndMap01IIIC := nestedSliceAndMap01IIV`,
  3309  				`			if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedSliceAndMap01", i), kk), "", nestedSliceAndMap01IIIC); err != nil {`,
  3310  				`			var nestedSliceAndMap01IIIR []map[string]strfmt.Date`,
  3311  				`			for iii, nestedSliceAndMap01IIIV := range nestedSliceAndMap01IIIC {`,
  3312  				`				nestedSliceAndMap01IIIIC := nestedSliceAndMap01IIIV`,
  3313  				`				nestedSliceAndMap01IIIIR := make(map[string]strfmt.Date, len(nestedSliceAndMap01IIIIC)`,
  3314  				`				for kkkk, nestedSliceAndMap01IIIIV := range nestedSliceAndMap01IIIIC {`,
  3315  				`					nestedSliceAndMap01IIII := nestedSliceAndMap01IIIIV`,
  3316  				`					if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedSliceAndMap01", i), kk), iii), kkkk), "", "date", nestedSliceAndMap01IIII.String(), formats); err != nil {`,
  3317  				`					nestedSliceAndMap01IIIIR[kkkk] = nestedSliceAndMap01IIII`,
  3318  				`				nestedSliceAndMap01IIIR = append(nestedSliceAndMap01IIIR, nestedSliceAndMap01IIIIR`,
  3319  				`			nestedSliceAndMap01IIR[kk] = nestedSliceAndMap01IIIR`,
  3320  				`		nestedSliceAndMap01IR = append(nestedSliceAndMap01IR, nestedSliceAndMap01IIR`,
  3321  				`	o.NestedSliceAndMap01 = nestedSliceAndMap01IR`,
  3322  			},
  3323  		},
  3324  
  3325  		// load expectations for parameters in operation get_nested_map_and_slice02_parameters.go
  3326  		"getNestedMapAndSlice02": { // fixture index
  3327  			"serverParameter": { // executed template
  3328  				// expected code lines
  3329  				`func NewGetNestedMapAndSlice02Params() GetNestedMapAndSlice02Params {`,
  3330  				`	return GetNestedMapAndSlice02Params{`,
  3331  				`type GetNestedMapAndSlice02Params struct {`,
  3332  				"	HTTPRequest *http.Request `json:\"-\"`",
  3333  				`	NestedMapAndSlice02 map[string][]map[string][]map[string]*int64`,
  3334  				`func (o *GetNestedMapAndSlice02Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3335  				`	o.HTTPRequest = r`,
  3336  				`	if runtime.HasBody(r) {`,
  3337  				`		defer r.Body.Close(`,
  3338  				`		var body map[string][]map[string][]map[string]*int64`,
  3339  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3340  				`			if err == io.EOF {`,
  3341  				`				res = append(res, errors.Required("nestedMapAndSlice02", "body")`,
  3342  				`			} else {`,
  3343  				`				res = append(res, errors.NewParseError("nestedMapAndSlice02", "body", "", err)`,
  3344  				`		} else {`,
  3345  				`			o.NestedMapAndSlice02 = body`,
  3346  				`			if err := o.validateNestedMapAndSlice02Body(route.Formats); err != nil {`,
  3347  				`	} else {`,
  3348  				`		res = append(res, errors.Required("nestedMapAndSlice02", "body")`,
  3349  				`		return errors.CompositeValidationError(res...`,
  3350  				`func (o *GetNestedMapAndSlice02Params) validateNestedMapAndSlice02Body(formats strfmt.Registry) error {`,
  3351  				`	nestedMapAndSlice02IC := o.NestedMapAndSlice02`,
  3352  				`	nestedMapAndSlice02IR := make(map[string][]map[string][]map[string]*int64, len(nestedMapAndSlice02IC)`,
  3353  				`	for k, nestedMapAndSlice02IV := range nestedMapAndSlice02IC {`,
  3354  				`		nestedMapAndSlice02IIC := nestedMapAndSlice02IV`,
  3355  				`		if err := validate.UniqueItems(fmt.Sprintf("%s.%v", "nestedMapAndSlice02", k), "body", nestedMapAndSlice02IIC); err != nil {`,
  3356  				`		var nestedMapAndSlice02IIR []map[string][]map[string]*int64`,
  3357  				`		for ii, nestedMapAndSlice02IIV := range nestedMapAndSlice02IIC {`,
  3358  				`			nestedMapAndSlice02IIIC := nestedMapAndSlice02IIV`,
  3359  				`			nestedMapAndSlice02IIIR := make(map[string][]map[string]*int64, len(nestedMapAndSlice02IIIC)`,
  3360  				`			for kkk, nestedMapAndSlice02IIIV := range nestedMapAndSlice02IIIC {`,
  3361  				`				nestedMapAndSlice02IIIIC := nestedMapAndSlice02IIIV`,
  3362  				`				if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMapAndSlice02", k), ii), kkk), "", nestedMapAndSlice02IIIIC); err != nil {`,
  3363  				`				var nestedMapAndSlice02IIIIR []map[string]*int64`,
  3364  				`				for iiii, nestedMapAndSlice02IIIIV := range nestedMapAndSlice02IIIIC {`,
  3365  				`					nestedMapAndSlice02IIIIIC := nestedMapAndSlice02IIIIV`,
  3366  				`					nestedMapAndSlice02IIIIIR := make(map[string]*int64, len(nestedMapAndSlice02IIIIIC)`,
  3367  				`					for kkkkk, nestedMapAndSlice02IIIIIV := range nestedMapAndSlice02IIIIIC {`,
  3368  				`						if nestedMapAndSlice02IIIIIV == nil {`,
  3369  				`						nestedMapAndSlice02IIIII := nestedMapAndSlice02IIIIIV`,
  3370  				`						if err := validate.MinimumInt(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMapAndSlice02", k), ii), kkk), iiii), kkkkk), "", int64(*nestedMapAndSlice02IIIII), 0, false); err != nil {`,
  3371  				`						nestedMapAndSlice02IIIIIR[kkkkk] = nestedMapAndSlice02IIIII`,
  3372  				`					nestedMapAndSlice02IIIIR = append(nestedMapAndSlice02IIIIR, nestedMapAndSlice02IIIIIR`,
  3373  				`				nestedMapAndSlice02IIIR[kkk] = nestedMapAndSlice02IIIIR`,
  3374  				`			nestedMapAndSlice02IIR = append(nestedMapAndSlice02IIR, nestedMapAndSlice02IIIR`,
  3375  				`		nestedMapAndSlice02IR[k] = nestedMapAndSlice02IIR`,
  3376  				`	o.NestedMapAndSlice02 = nestedMapAndSlice02IR`,
  3377  			},
  3378  		},
  3379  
  3380  		// load expectations for parameters in operation get_nested_slice_and_map03_parameters.go
  3381  		"getNestedSliceAndMap03": { // fixture index
  3382  			"serverParameter": { // executed template
  3383  				// expected code lines
  3384  				`func NewGetNestedSliceAndMap03Params() GetNestedSliceAndMap03Params {`,
  3385  				`	return GetNestedSliceAndMap03Params{`,
  3386  				`type GetNestedSliceAndMap03Params struct {`,
  3387  				"	HTTPRequest *http.Request `json:\"-\"`",
  3388  				`	NestedSliceAndMap03 []map[string][]map[string]string`,
  3389  				`func (o *GetNestedSliceAndMap03Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3390  				`	o.HTTPRequest = r`,
  3391  				`	if runtime.HasBody(r) {`,
  3392  				`		defer r.Body.Close(`,
  3393  				`		var body []map[string][]map[string]string`,
  3394  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3395  				`			if err == io.EOF {`,
  3396  				`				res = append(res, errors.Required("nestedSliceAndMap03", "body")`,
  3397  				`			} else {`,
  3398  				`				res = append(res, errors.NewParseError("nestedSliceAndMap03", "body", "", err)`,
  3399  				`		} else {`,
  3400  				`			o.NestedSliceAndMap03 = body`,
  3401  				`			if err := o.validateNestedSliceAndMap03Body(route.Formats); err != nil {`,
  3402  				`	} else {`,
  3403  				`		res = append(res, errors.Required("nestedSliceAndMap03", "body")`,
  3404  				`		return errors.CompositeValidationError(res...`,
  3405  				`func (o *GetNestedSliceAndMap03Params) validateNestedSliceAndMap03Body(formats strfmt.Registry) error {`,
  3406  				`	if err := validate.UniqueItems("nestedSliceAndMap03", "body", o.NestedSliceAndMap03); err != nil {`,
  3407  				`	nestedSliceAndMap03IC := o.NestedSliceAndMap03`,
  3408  				`	var nestedSliceAndMap03IR []map[string][]map[string]string`,
  3409  				`	for i, nestedSliceAndMap03IV := range nestedSliceAndMap03IC {`,
  3410  				`		nestedSliceAndMap03IIC := nestedSliceAndMap03IV`,
  3411  				`		nestedSliceAndMap03IIR := make(map[string][]map[string]string, len(nestedSliceAndMap03IIC)`,
  3412  				`		for kk, nestedSliceAndMap03IIV := range nestedSliceAndMap03IIC {`,
  3413  				`			nestedSliceAndMap03IIIC := nestedSliceAndMap03IIV`,
  3414  				`			if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedSliceAndMap03", i), kk), "", nestedSliceAndMap03IIIC); err != nil {`,
  3415  				`			var nestedSliceAndMap03IIIR []map[string]string`,
  3416  				`			for _, nestedSliceAndMap03IIIV := range nestedSliceAndMap03IIIC {`,
  3417  				`				nestedSliceAndMap03IIIIC := nestedSliceAndMap03IIIV`,
  3418  				`				nestedSliceAndMap03IIIIR := make(map[string]string, len(nestedSliceAndMap03IIIIC)`,
  3419  				`				for kkkk, nestedSliceAndMap03IIIIV := range nestedSliceAndMap03IIIIC {`,
  3420  				`					nestedSliceAndMap03IIII := nestedSliceAndMap03IIIIV`,
  3421  				`					nestedSliceAndMap03IIIIR[kkkk] = nestedSliceAndMap03IIII`,
  3422  				`				nestedSliceAndMap03IIIR = append(nestedSliceAndMap03IIIR, nestedSliceAndMap03IIIIR`,
  3423  				`			nestedSliceAndMap03IIR[kk] = nestedSliceAndMap03IIIR`,
  3424  				`		nestedSliceAndMap03IR = append(nestedSliceAndMap03IR, nestedSliceAndMap03IIR`,
  3425  				`	o.NestedSliceAndMap03 = nestedSliceAndMap03IR`,
  3426  			},
  3427  		},
  3428  
  3429  		// load expectations for parameters in operation get_nested_array03_parameters.go
  3430  		"getNestedArray03": { // fixture index
  3431  			"serverParameter": { // executed template
  3432  				// expected code lines
  3433  				`func NewGetNestedArray03Params() GetNestedArray03Params {`,
  3434  				`	return GetNestedArray03Params{`,
  3435  				`type GetNestedArray03Params struct {`,
  3436  				"	HTTPRequest *http.Request `json:\"-\"`",
  3437  				`	NestedArray03 [][][]string`,
  3438  				`func (o *GetNestedArray03Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3439  				`	o.HTTPRequest = r`,
  3440  				`	if runtime.HasBody(r) {`,
  3441  				`		defer r.Body.Close(`,
  3442  				`		var body [][][]string`,
  3443  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3444  				`			if err == io.EOF {`,
  3445  				`				res = append(res, errors.Required("nestedArray03", "body")`,
  3446  				`			} else {`,
  3447  				`				res = append(res, errors.NewParseError("nestedArray03", "body", "", err)`,
  3448  				`		} else {`,
  3449  				`			o.NestedArray03 = body`,
  3450  				`	} else {`,
  3451  				`		res = append(res, errors.Required("nestedArray03", "body")`,
  3452  				`		return errors.CompositeValidationError(res...`,
  3453  			},
  3454  		},
  3455  
  3456  		// load expectations for parameters in operation get_nested_array04_parameters.go
  3457  		"getNestedArray04": { // fixture index
  3458  			"serverParameter": { // executed template
  3459  				// expected code lines
  3460  				`func NewGetNestedArray04Params() GetNestedArray04Params {`,
  3461  				`	return GetNestedArray04Params{`,
  3462  				`type GetNestedArray04Params struct {`,
  3463  				"	HTTPRequest *http.Request `json:\"-\"`",
  3464  				`	NestedArray03 [][][]string`,
  3465  				`func (o *GetNestedArray04Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3466  				`	o.HTTPRequest = r`,
  3467  				`	if runtime.HasBody(r) {`,
  3468  				`		defer r.Body.Close(`,
  3469  				`		var body [][][]string`,
  3470  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3471  				`			if err == io.EOF {`,
  3472  				`				res = append(res, errors.Required("nestedArray03", "body")`,
  3473  				`			} else {`,
  3474  				`				res = append(res, errors.NewParseError("nestedArray03", "body", "", err)`,
  3475  				`		} else {`,
  3476  				`			o.NestedArray03 = body`,
  3477  				`			if err := o.validateNestedArray03Body(route.Formats); err != nil {`,
  3478  				`	} else {`,
  3479  				`		res = append(res, errors.Required("nestedArray03", "body")`,
  3480  				`		return errors.CompositeValidationError(res...`,
  3481  				`func (o *GetNestedArray04Params) validateNestedArray03Body(formats strfmt.Registry) error {`,
  3482  				`	if err := validate.UniqueItems("nestedArray03", "body", o.NestedArray03); err != nil {`,
  3483  				`	nestedArray03IC := o.NestedArray03`,
  3484  				`	var nestedArray03IR [][][]string`,
  3485  				`	for i, nestedArray03IV := range nestedArray03IC {`,
  3486  				`		nestedArray03IIC := nestedArray03IV`,
  3487  				`		if err := validate.UniqueItems(fmt.Sprintf("%s.%v", "nestedArray03", i), "body", nestedArray03IIC); err != nil {`,
  3488  				`		if len(nestedArray03IIC) > 0 {`,
  3489  				`			var nestedArray03IIR [][]string`,
  3490  				`			for ii, nestedArray03IIV := range nestedArray03IIC {`,
  3491  				`				nestedArray03IIIC := nestedArray03IIV`,
  3492  				`				if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedArray03", i), ii), "", nestedArray03IIIC); err != nil {`,
  3493  				`				if len(nestedArray03IIIC) > 0 {`,
  3494  				`					var nestedArray03IIIR []string`,
  3495  				`					for _, nestedArray03IIIV := range nestedArray03IIIC {`,
  3496  				`						nestedArray03III := nestedArray03IIIV`,
  3497  				`						nestedArray03IIIR = append(nestedArray03IIIR, nestedArray03III`,
  3498  				`					nestedArray03IIR = append(nestedArray03IIR, nestedArray03IIIR`,
  3499  				`			nestedArray03IR = append(nestedArray03IR, nestedArray03IIR`,
  3500  				`	o.NestedArray03 = nestedArray03IR`,
  3501  			},
  3502  		},
  3503  
  3504  		// load expectations for parameters in operation get_nested_map_and_slice01_parameters.go
  3505  		"getNestedMapAndSlice01": { // fixture index
  3506  			"serverParameter": { // executed template
  3507  				// expected code lines
  3508  				`func NewGetNestedMapAndSlice01Params() GetNestedMapAndSlice01Params {`,
  3509  				`	return GetNestedMapAndSlice01Params{`,
  3510  				`type GetNestedMapAndSlice01Params struct {`,
  3511  				"	HTTPRequest *http.Request `json:\"-\"`",
  3512  				`	NestedMapAndSlice01 map[string][]map[string][]map[string]strfmt.Date`,
  3513  				`func (o *GetNestedMapAndSlice01Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3514  				`	o.HTTPRequest = r`,
  3515  				`	if runtime.HasBody(r) {`,
  3516  				`		defer r.Body.Close(`,
  3517  				`		var body map[string][]map[string][]map[string]strfmt.Date`,
  3518  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3519  				`			if err == io.EOF {`,
  3520  				`				res = append(res, errors.Required("nestedMapAndSlice01", "body")`,
  3521  				`			} else {`,
  3522  				`				res = append(res, errors.NewParseError("nestedMapAndSlice01", "body", "", err)`,
  3523  				`		} else {`,
  3524  				`			o.NestedMapAndSlice01 = body`,
  3525  				`			if err := o.validateNestedMapAndSlice01Body(route.Formats); err != nil {`,
  3526  				`	} else {`,
  3527  				`		res = append(res, errors.Required("nestedMapAndSlice01", "body")`,
  3528  				`		return errors.CompositeValidationError(res...`,
  3529  				`func (o *GetNestedMapAndSlice01Params) validateNestedMapAndSlice01Body(formats strfmt.Registry) error {`,
  3530  				`	nestedMapAndSlice01IC := o.NestedMapAndSlice01`,
  3531  				`	nestedMapAndSlice01IR := make(map[string][]map[string][]map[string]strfmt.Date, len(nestedMapAndSlice01IC)`,
  3532  				`	for k, nestedMapAndSlice01IV := range nestedMapAndSlice01IC {`,
  3533  				`		nestedMapAndSlice01IIC := nestedMapAndSlice01IV`,
  3534  				`		if err := validate.UniqueItems(fmt.Sprintf("%s.%v", "nestedMapAndSlice01", k), "body", nestedMapAndSlice01IIC); err != nil {`,
  3535  				`		var nestedMapAndSlice01IIR []map[string][]map[string]strfmt.Date`,
  3536  				`		for ii, nestedMapAndSlice01IIV := range nestedMapAndSlice01IIC {`,
  3537  				`			nestedMapAndSlice01IIIC := nestedMapAndSlice01IIV`,
  3538  				`			nestedMapAndSlice01IIIR := make(map[string][]map[string]strfmt.Date, len(nestedMapAndSlice01IIIC)`,
  3539  				`			for kkk, nestedMapAndSlice01IIIV := range nestedMapAndSlice01IIIC {`,
  3540  				`				nestedMapAndSlice01IIIIC := nestedMapAndSlice01IIIV`,
  3541  				`				if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMapAndSlice01", k), ii), kkk), "", nestedMapAndSlice01IIIIC); err != nil {`,
  3542  				`				var nestedMapAndSlice01IIIIR []map[string]strfmt.Date`,
  3543  				`				for iiii, nestedMapAndSlice01IIIIV := range nestedMapAndSlice01IIIIC {`,
  3544  				`					nestedMapAndSlice01IIIIIC := nestedMapAndSlice01IIIIV`,
  3545  				`					nestedMapAndSlice01IIIIIR := make(map[string]strfmt.Date, len(nestedMapAndSlice01IIIIIC)`,
  3546  				`					for kkkkk, nestedMapAndSlice01IIIIIV := range nestedMapAndSlice01IIIIIC {`,
  3547  				`						nestedMapAndSlice01IIIII := nestedMapAndSlice01IIIIIV`,
  3548  				`						if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMapAndSlice01", k), ii), kkk), iiii), kkkkk), "", "date", nestedMapAndSlice01IIIII.String(), formats); err != nil {`,
  3549  				`						nestedMapAndSlice01IIIIIR[kkkkk] = nestedMapAndSlice01IIIII`,
  3550  				`					nestedMapAndSlice01IIIIR = append(nestedMapAndSlice01IIIIR, nestedMapAndSlice01IIIIIR`,
  3551  				`				nestedMapAndSlice01IIIR[kkk] = nestedMapAndSlice01IIIIR`,
  3552  				`			nestedMapAndSlice01IIR = append(nestedMapAndSlice01IIR, nestedMapAndSlice01IIIR`,
  3553  				`		nestedMapAndSlice01IR[k] = nestedMapAndSlice01IIR`,
  3554  				`	o.NestedMapAndSlice01 = nestedMapAndSlice01IR`,
  3555  			},
  3556  		},
  3557  
  3558  		// load expectations for parameters in operation get_nested_slice_and_map03_ref_parameters.go
  3559  		"getNestedSliceAndMap03Ref": { // fixture index
  3560  			"serverParameter": { // executed template
  3561  				// expected code lines
  3562  				`func NewGetNestedSliceAndMap03RefParams() GetNestedSliceAndMap03RefParams {`,
  3563  				`	return GetNestedSliceAndMap03RefParams{`,
  3564  				`type GetNestedSliceAndMap03RefParams struct {`,
  3565  				"	HTTPRequest *http.Request `json:\"-\"`",
  3566  				`	NestedSliceAndMap03Ref models.NestedSliceAndMap03Ref`,
  3567  				`func (o *GetNestedSliceAndMap03RefParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3568  				`	o.HTTPRequest = r`,
  3569  				`	if runtime.HasBody(r) {`,
  3570  				`		defer r.Body.Close(`,
  3571  				`		var body models.NestedSliceAndMap03Ref`,
  3572  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3573  				`			res = append(res, errors.NewParseError("nestedSliceAndMap03Ref", "body", "", err)`,
  3574  				`		} else {`,
  3575  				`			if err := body.Validate(route.Formats); err != nil {`,
  3576  				`			if len(res) == 0 {`,
  3577  				`				o.NestedSliceAndMap03Ref = body`,
  3578  				`		return errors.CompositeValidationError(res...`,
  3579  			},
  3580  		},
  3581  
  3582  		// load expectations for parameters in operation get_nested_map02_parameters.go
  3583  		"getNestedMap02": { // fixture index
  3584  			"serverParameter": { // executed template
  3585  				// expected code lines
  3586  				`func NewGetNestedMap02Params() GetNestedMap02Params {`,
  3587  				`	return GetNestedMap02Params{`,
  3588  				`type GetNestedMap02Params struct {`,
  3589  				"	HTTPRequest *http.Request `json:\"-\"`",
  3590  				`	NestedMap02 map[string]map[string]map[string]*string`,
  3591  				`func (o *GetNestedMap02Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3592  				`	o.HTTPRequest = r`,
  3593  				`	if runtime.HasBody(r) {`,
  3594  				`		defer r.Body.Close(`,
  3595  				`		var body map[string]map[string]map[string]*string`,
  3596  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3597  				`			if err == io.EOF {`,
  3598  				`				res = append(res, errors.Required("nestedMap02", "body")`,
  3599  				`			} else {`,
  3600  				`				res = append(res, errors.NewParseError("nestedMap02", "body", "", err)`,
  3601  				`		} else {`,
  3602  				`			o.NestedMap02 = body`,
  3603  				`			if err := o.validateNestedMap02Body(route.Formats); err != nil {`,
  3604  				`	} else {`,
  3605  				`		res = append(res, errors.Required("nestedMap02", "body")`,
  3606  				`		return errors.CompositeValidationError(res...`,
  3607  				`func (o *GetNestedMap02Params) validateNestedMap02Body(formats strfmt.Registry) error {`,
  3608  				`	nestedMap02IC := o.NestedMap02`,
  3609  				`	nestedMap02IR := make(map[string]map[string]map[string]*string, len(nestedMap02IC)`,
  3610  				`	for k, nestedMap02IV := range nestedMap02IC {`,
  3611  				`		nestedMap02IIC := nestedMap02IV`,
  3612  				`		nestedMap02IIR := make(map[string]map[string]*string, len(nestedMap02IIC)`,
  3613  				`		for kk, nestedMap02IIV := range nestedMap02IIC {`,
  3614  				`			nestedMap02IIIC := nestedMap02IIV`,
  3615  				`			nestedMap02IIIR := make(map[string]*string, len(nestedMap02IIIC)`,
  3616  				`			for kkk, nestedMap02IIIV := range nestedMap02IIIC {`,
  3617  				`				if nestedMap02IIIV == nil {`,
  3618  				`				nestedMap02III := nestedMap02IIIV`,
  3619  				`				if err := validate.MinLength(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMap02", k), kk), kkk), "", (*nestedMap02III), 0); err != nil {`,
  3620  				`				nestedMap02IIIR[kkk] = nestedMap02III`,
  3621  				`			nestedMap02IIR[kk] = nestedMap02IIIR`,
  3622  				`		nestedMap02IR[k] = nestedMap02IIR`,
  3623  				`	o.NestedMap02 = nestedMap02IR`,
  3624  			},
  3625  		},
  3626  
  3627  		// load expectations for parameters in operation get_nested_map_and_slice03_parameters.go
  3628  		"getNestedMapAndSlice03": { // fixture index
  3629  			"serverParameter": { // executed template
  3630  				// expected code lines
  3631  				`func NewGetNestedMapAndSlice03Params() GetNestedMapAndSlice03Params {`,
  3632  				`	return GetNestedMapAndSlice03Params{`,
  3633  				`type GetNestedMapAndSlice03Params struct {`,
  3634  				"	HTTPRequest *http.Request `json:\"-\"`",
  3635  				`	NestedMapAndSlice03 map[string][]map[string][]map[string]int64`,
  3636  				`func (o *GetNestedMapAndSlice03Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3637  				`	o.HTTPRequest = r`,
  3638  				`	if runtime.HasBody(r) {`,
  3639  				`		defer r.Body.Close(`,
  3640  				`		var body map[string][]map[string][]map[string]int64`,
  3641  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3642  				`			if err == io.EOF {`,
  3643  				`				res = append(res, errors.Required("nestedMapAndSlice03", "body")`,
  3644  				`			} else {`,
  3645  				`				res = append(res, errors.NewParseError("nestedMapAndSlice03", "body", "", err)`,
  3646  				`		} else {`,
  3647  				`			o.NestedMapAndSlice03 = body`,
  3648  				`			if err := o.validateNestedMapAndSlice03Body(route.Formats); err != nil {`,
  3649  				`	} else {`,
  3650  				`		res = append(res, errors.Required("nestedMapAndSlice03", "body")`,
  3651  				`		return errors.CompositeValidationError(res...`,
  3652  				`func (o *GetNestedMapAndSlice03Params) validateNestedMapAndSlice03Body(formats strfmt.Registry) error {`,
  3653  				`	nestedMapAndSlice03IC := o.NestedMapAndSlice03`,
  3654  				`	nestedMapAndSlice03IR := make(map[string][]map[string][]map[string]int64, len(nestedMapAndSlice03IC)`,
  3655  				`	for k, nestedMapAndSlice03IV := range nestedMapAndSlice03IC {`,
  3656  				`		nestedMapAndSlice03IIC := nestedMapAndSlice03IV`,
  3657  				`		if err := validate.UniqueItems(fmt.Sprintf("%s.%v", "nestedMapAndSlice03", k), "body", nestedMapAndSlice03IIC); err != nil {`,
  3658  				`		var nestedMapAndSlice03IIR []map[string][]map[string]int64`,
  3659  				`		for ii, nestedMapAndSlice03IIV := range nestedMapAndSlice03IIC {`,
  3660  				`			nestedMapAndSlice03IIIC := nestedMapAndSlice03IIV`,
  3661  				`			nestedMapAndSlice03IIIR := make(map[string][]map[string]int64, len(nestedMapAndSlice03IIIC)`,
  3662  				`			for kkk, nestedMapAndSlice03IIIV := range nestedMapAndSlice03IIIC {`,
  3663  				`				nestedMapAndSlice03IIIIC := nestedMapAndSlice03IIIV`,
  3664  				`				if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMapAndSlice03", k), ii), kkk), "", nestedMapAndSlice03IIIIC); err != nil {`,
  3665  				`				var nestedMapAndSlice03IIIIR []map[string]int64`,
  3666  				`				for _, nestedMapAndSlice03IIIIV := range nestedMapAndSlice03IIIIC {`,
  3667  				`					nestedMapAndSlice03IIIIIC := nestedMapAndSlice03IIIIV`,
  3668  				`					nestedMapAndSlice03IIIIIR := make(map[string]int64, len(nestedMapAndSlice03IIIIIC)`,
  3669  				`					for kkkkk, nestedMapAndSlice03IIIIIV := range nestedMapAndSlice03IIIIIC {`,
  3670  				`						nestedMapAndSlice03IIIII := nestedMapAndSlice03IIIIIV`,
  3671  				`						nestedMapAndSlice03IIIIIR[kkkkk] = nestedMapAndSlice03IIIII`,
  3672  				`					nestedMapAndSlice03IIIIR = append(nestedMapAndSlice03IIIIR, nestedMapAndSlice03IIIIIR`,
  3673  				`				nestedMapAndSlice03IIIR[kkk] = nestedMapAndSlice03IIIIR`,
  3674  				`			nestedMapAndSlice03IIR = append(nestedMapAndSlice03IIR, nestedMapAndSlice03IIIR`,
  3675  				`		nestedMapAndSlice03IR[k] = nestedMapAndSlice03IIR`,
  3676  				`	o.NestedMapAndSlice03 = nestedMapAndSlice03IR`,
  3677  			},
  3678  		},
  3679  
  3680  		// load expectations for parameters in operation get_nested_slice_and_map02_parameters.go
  3681  		"getNestedSliceAndMap02": { // fixture index
  3682  			"serverParameter": { // executed template
  3683  				// expected code lines
  3684  				`func NewGetNestedSliceAndMap02Params() GetNestedSliceAndMap02Params {`,
  3685  				`	return GetNestedSliceAndMap02Params{`,
  3686  				`type GetNestedSliceAndMap02Params struct {`,
  3687  				"	HTTPRequest *http.Request `json:\"-\"`",
  3688  				`	NestedSliceAndMap02 []map[string][]map[string]*string`,
  3689  				`func (o *GetNestedSliceAndMap02Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3690  				`	o.HTTPRequest = r`,
  3691  				`	if runtime.HasBody(r) {`,
  3692  				`		defer r.Body.Close(`,
  3693  				`		var body []map[string][]map[string]*string`,
  3694  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3695  				`			if err == io.EOF {`,
  3696  				`				res = append(res, errors.Required("nestedSliceAndMap02", "body")`,
  3697  				`			} else {`,
  3698  				`				res = append(res, errors.NewParseError("nestedSliceAndMap02", "body", "", err)`,
  3699  				`		} else {`,
  3700  				`			o.NestedSliceAndMap02 = body`,
  3701  				`			if err := o.validateNestedSliceAndMap02Body(route.Formats); err != nil {`,
  3702  				`	} else {`,
  3703  				`		res = append(res, errors.Required("nestedSliceAndMap02", "body")`,
  3704  				`		return errors.CompositeValidationError(res...`,
  3705  				`func (o *GetNestedSliceAndMap02Params) validateNestedSliceAndMap02Body(formats strfmt.Registry) error {`,
  3706  				`	if err := validate.UniqueItems("nestedSliceAndMap02", "body", o.NestedSliceAndMap02); err != nil {`,
  3707  				`	nestedSliceAndMap02IC := o.NestedSliceAndMap02`,
  3708  				`	var nestedSliceAndMap02IR []map[string][]map[string]*string`,
  3709  				`	for i, nestedSliceAndMap02IV := range nestedSliceAndMap02IC {`,
  3710  				`		nestedSliceAndMap02IIC := nestedSliceAndMap02IV`,
  3711  				`		nestedSliceAndMap02IIR := make(map[string][]map[string]*string, len(nestedSliceAndMap02IIC)`,
  3712  				`		for kk, nestedSliceAndMap02IIV := range nestedSliceAndMap02IIC {`,
  3713  				`			nestedSliceAndMap02IIIC := nestedSliceAndMap02IIV`,
  3714  				`			if err := validate.UniqueItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedSliceAndMap02", i), kk), "", nestedSliceAndMap02IIIC); err != nil {`,
  3715  				`			var nestedSliceAndMap02IIIR []map[string]*string`,
  3716  				`			for iii, nestedSliceAndMap02IIIV := range nestedSliceAndMap02IIIC {`,
  3717  				`				nestedSliceAndMap02IIIIC := nestedSliceAndMap02IIIV`,
  3718  				`				nestedSliceAndMap02IIIIR := make(map[string]*string, len(nestedSliceAndMap02IIIIC)`,
  3719  				`				for kkkk, nestedSliceAndMap02IIIIV := range nestedSliceAndMap02IIIIC {`,
  3720  				`					if nestedSliceAndMap02IIIIV == nil {`,
  3721  				`					nestedSliceAndMap02IIII := nestedSliceAndMap02IIIIV`,
  3722  				`					if err := validate.MinLength(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedSliceAndMap02", i), kk), iii), kkkk), "", (*nestedSliceAndMap02IIII), 0); err != nil {`,
  3723  				`					nestedSliceAndMap02IIIIR[kkkk] = nestedSliceAndMap02IIII`,
  3724  				`				nestedSliceAndMap02IIIR = append(nestedSliceAndMap02IIIR, nestedSliceAndMap02IIIIR`,
  3725  				`			nestedSliceAndMap02IIR[kk] = nestedSliceAndMap02IIIR`,
  3726  				`		nestedSliceAndMap02IR = append(nestedSliceAndMap02IR, nestedSliceAndMap02IIR`,
  3727  				`	o.NestedSliceAndMap02 = nestedSliceAndMap02IR`,
  3728  			},
  3729  		},
  3730  
  3731  		// load expectations for parameters in operation get_nested_map01_parameters.go
  3732  		"getNestedMap01": { // fixture index
  3733  			"serverParameter": { // executed template
  3734  				// expected code lines
  3735  				`func NewGetNestedMap01Params() GetNestedMap01Params {`,
  3736  				`	return GetNestedMap01Params{`,
  3737  				`type GetNestedMap01Params struct {`,
  3738  				"	HTTPRequest *http.Request `json:\"-\"`",
  3739  				`	NestedMap01 map[string]map[string]map[string]strfmt.Date`,
  3740  				`func (o *GetNestedMap01Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3741  				`	o.HTTPRequest = r`,
  3742  				`	if runtime.HasBody(r) {`,
  3743  				`		defer r.Body.Close(`,
  3744  				`		var body map[string]map[string]map[string]strfmt.Date`,
  3745  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3746  				`			if err == io.EOF {`,
  3747  				`				res = append(res, errors.Required("nestedMap01", "body")`,
  3748  				`			} else {`,
  3749  				`				res = append(res, errors.NewParseError("nestedMap01", "body", "", err)`,
  3750  				`		} else {`,
  3751  				`			o.NestedMap01 = body`,
  3752  				`			if err := o.validateNestedMap01Body(route.Formats); err != nil {`,
  3753  				`	} else {`,
  3754  				`		res = append(res, errors.Required("nestedMap01", "body")`,
  3755  				`		return errors.CompositeValidationError(res...`,
  3756  				`func (o *GetNestedMap01Params) validateNestedMap01Body(formats strfmt.Registry) error {`,
  3757  				`	nestedMap01IC := o.NestedMap01`,
  3758  				`	nestedMap01IR := make(map[string]map[string]map[string]strfmt.Date, len(nestedMap01IC)`,
  3759  				`	for k, nestedMap01IV := range nestedMap01IC {`,
  3760  				`		nestedMap01IIC := nestedMap01IV`,
  3761  				`		nestedMap01IIR := make(map[string]map[string]strfmt.Date, len(nestedMap01IIC)`,
  3762  				`		for kk, nestedMap01IIV := range nestedMap01IIC {`,
  3763  				`			nestedMap01IIIC := nestedMap01IIV`,
  3764  				`			nestedMap01IIIR := make(map[string]strfmt.Date, len(nestedMap01IIIC)`,
  3765  				`			for kkk, nestedMap01IIIV := range nestedMap01IIIC {`,
  3766  				`				nestedMap01III := nestedMap01IIIV`,
  3767  				`				if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedMap01", k), kk), kkk), "", "date", nestedMap01III.String(), formats); err != nil {`,
  3768  				`				nestedMap01IIIR[kkk] = nestedMap01III`,
  3769  				`			nestedMap01IIR[kk] = nestedMap01IIIR`,
  3770  				`		nestedMap01IR[k] = nestedMap01IIR`,
  3771  				`	o.NestedMap01 = nestedMap01IR`,
  3772  			},
  3773  		},
  3774  
  3775  		// load expectations for parameters in operation get_nested_map03_parameters.go
  3776  		"getNestedMap03": { // fixture index
  3777  			"serverParameter": { // executed template
  3778  				// expected code lines
  3779  				`func NewGetNestedMap03Params() GetNestedMap03Params {`,
  3780  				`	return GetNestedMap03Params{`,
  3781  				`type GetNestedMap03Params struct {`,
  3782  				"	HTTPRequest *http.Request `json:\"-\"`",
  3783  				`	NestedMap03 map[string]map[string]map[string]string`,
  3784  				`func (o *GetNestedMap03Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3785  				`	o.HTTPRequest = r`,
  3786  				`	if runtime.HasBody(r) {`,
  3787  				`		defer r.Body.Close(`,
  3788  				`		var body map[string]map[string]map[string]string`,
  3789  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3790  				`			if err == io.EOF {`,
  3791  				`				res = append(res, errors.Required("nestedMap03", "body")`,
  3792  				`			} else {`,
  3793  				`				res = append(res, errors.NewParseError("nestedMap03", "body", "", err)`,
  3794  				`		} else {`,
  3795  				`			o.NestedMap03 = body`,
  3796  				`	} else {`,
  3797  				`		res = append(res, errors.Required("nestedMap03", "body")`,
  3798  				`		return errors.CompositeValidationError(res...`,
  3799  			},
  3800  		},
  3801  
  3802  		// load expectations for parameters in operation get_nested_array01_parameters.go
  3803  		"getNestedArray01": { // fixture index
  3804  			"serverParameter": { // executed template
  3805  				// expected code lines
  3806  				`func NewGetNestedArray01Params() GetNestedArray01Params {`,
  3807  				`	return GetNestedArray01Params{`,
  3808  				`type GetNestedArray01Params struct {`,
  3809  				"	HTTPRequest *http.Request `json:\"-\"`",
  3810  				`	NestedArray01 [][][]strfmt.Date`,
  3811  				`func (o *GetNestedArray01Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3812  				`	o.HTTPRequest = r`,
  3813  				`	if runtime.HasBody(r) {`,
  3814  				`		defer r.Body.Close(`,
  3815  				`		var body [][][]strfmt.Date`,
  3816  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3817  				`			if err == io.EOF {`,
  3818  				`				res = append(res, errors.Required("nestedArray01", "body")`,
  3819  				`			} else {`,
  3820  				`				res = append(res, errors.NewParseError("nestedArray01", "body", "", err)`,
  3821  				`		} else {`,
  3822  				`			o.NestedArray01 = body`,
  3823  				`			if err := o.validateNestedArray01Body(route.Formats); err != nil {`,
  3824  				`	} else {`,
  3825  				`		res = append(res, errors.Required("nestedArray01", "body")`,
  3826  				`		return errors.CompositeValidationError(res...`,
  3827  				`func (o *GetNestedArray01Params) validateNestedArray01Body(formats strfmt.Registry) error {`,
  3828  				`	nestedArray01Size := int64(len(o.NestedArray01)`,
  3829  				`	if err := validate.MaxItems("nestedArray01", "body", nestedArray01Size, 10); err != nil {`,
  3830  				`	nestedArray01IC := o.NestedArray01`,
  3831  				`	var nestedArray01IR [][][]strfmt.Date`,
  3832  				`	for i, nestedArray01IV := range nestedArray01IC {`,
  3833  				`		nestedArray01IIC := nestedArray01IV`,
  3834  				`		nestedArray01ISize := int64(len(nestedArray01IIC)`,
  3835  				`		if err := validate.MaxItems(fmt.Sprintf("%s.%v", "nestedArray01", i), "body", nestedArray01ISize, 10); err != nil {`,
  3836  				`		if len(nestedArray01IIC) > 0 {`,
  3837  				`			var nestedArray01IIR [][]strfmt.Date`,
  3838  				`			for ii, nestedArray01IIV := range nestedArray01IIC {`,
  3839  				`				nestedArray01IIIC := nestedArray01IIV`,
  3840  				`				nestedArray01IiiSize := int64(len(nestedArray01IIIC)`,
  3841  				`				if err := validate.MaxItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedArray01", i), ii), "", nestedArray01IiiSize, 10); err != nil {`,
  3842  				`				if len(nestedArray01IIIC) > 0 {`,
  3843  				`					var nestedArray01IIIR []strfmt.Date`,
  3844  				`					for iii, nestedArray01IIIV := range nestedArray01IIIC {`,
  3845  				`						nestedArray01III := nestedArray01IIIV`,
  3846  				`						if err := validate.FormatOf(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedArray01", i), ii), iii), "", "date", nestedArray01III.String(), formats); err != nil {`,
  3847  				`						nestedArray01IIIR = append(nestedArray01IIIR, nestedArray01III`,
  3848  				`					nestedArray01IIR = append(nestedArray01IIR, nestedArray01IIIR`,
  3849  				`			nestedArray01IR = append(nestedArray01IR, nestedArray01IIR`,
  3850  				`	o.NestedArray01 = nestedArray01IR`,
  3851  			},
  3852  		},
  3853  
  3854  		// load expectations for parameters in operation get_nested_array02_parameters.go
  3855  		"getNestedArray02": { // fixture index
  3856  			"serverParameter": { // executed template
  3857  				// expected code lines
  3858  				`func NewGetNestedArray02Params() GetNestedArray02Params {`,
  3859  				`	return GetNestedArray02Params{`,
  3860  				`type GetNestedArray02Params struct {`,
  3861  				"	HTTPRequest *http.Request `json:\"-\"`",
  3862  				`	NestedArray01 [][][]*string`,
  3863  				`func (o *GetNestedArray02Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3864  				`	o.HTTPRequest = r`,
  3865  				`	if runtime.HasBody(r) {`,
  3866  				`		defer r.Body.Close(`,
  3867  				`		var body [][][]*string`,
  3868  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3869  				`			if err == io.EOF {`,
  3870  				`				res = append(res, errors.Required("nestedArray01", "body")`,
  3871  				`			} else {`,
  3872  				`				res = append(res, errors.NewParseError("nestedArray01", "body", "", err)`,
  3873  				`		} else {`,
  3874  				`			o.NestedArray01 = body`,
  3875  				`			if err := o.validateNestedArray01Body(route.Formats); err != nil {`,
  3876  				`	} else {`,
  3877  				`		res = append(res, errors.Required("nestedArray01", "body")`,
  3878  				`		return errors.CompositeValidationError(res...`,
  3879  				`func (o *GetNestedArray02Params) validateNestedArray01Body(formats strfmt.Registry) error {`,
  3880  				`	nestedArray01Size := int64(len(o.NestedArray01)`,
  3881  				`	if err := validate.MaxItems("nestedArray01", "body", nestedArray01Size, 10); err != nil {`,
  3882  				`	nestedArray01IC := o.NestedArray01`,
  3883  				`	var nestedArray01IR [][][]*string`,
  3884  				`	for i, nestedArray01IV := range nestedArray01IC {`,
  3885  				`		nestedArray01IIC := nestedArray01IV`,
  3886  				`		nestedArray01ISize := int64(len(nestedArray01IIC)`,
  3887  				`		if err := validate.MaxItems(fmt.Sprintf("%s.%v", "nestedArray01", i), "body", nestedArray01ISize, 10); err != nil {`,
  3888  				`		if len(nestedArray01IIC) > 0 {`,
  3889  				`			var nestedArray01IIR [][]*string`,
  3890  				`			for ii, nestedArray01IIV := range nestedArray01IIC {`,
  3891  				`				nestedArray01IIIC := nestedArray01IIV`,
  3892  				`				nestedArray01IiiSize := int64(len(nestedArray01IIIC)`,
  3893  				`				if err := validate.MaxItems(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedArray01", i), ii), "", nestedArray01IiiSize, 10); err != nil {`,
  3894  				`				if len(nestedArray01IIIC) > 0 {`,
  3895  				`					var nestedArray01IIIR []*string`,
  3896  				`					for iii, nestedArray01IIIV := range nestedArray01IIIC {`,
  3897  				`						if nestedArray01IIIV == nil {`,
  3898  				// do we need Required on nullable in items?
  3899  				// without Required
  3900  				`							continue`,
  3901  				// with Required
  3902  				//`							return errors.Required(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedArray01", i), ii), iii), ""`,
  3903  				`						nestedArray01III := nestedArray01IIIV`,
  3904  				`						if err := validate.MinLength(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedArray01", i), ii), iii), "", (*nestedArray01III), 0); err != nil {`,
  3905  				`						nestedArray01IIIR = append(nestedArray01IIIR, nestedArray01III`,
  3906  				`					nestedArray01IIR = append(nestedArray01IIR, nestedArray01IIIR`,
  3907  				`			nestedArray01IR = append(nestedArray01IR, nestedArray01IIR`,
  3908  				`	o.NestedArray01 = nestedArray01IR`,
  3909  			},
  3910  		},
  3911  		// load expectations for parameters in operation get_nested_ref_no_validation01_parameters.go
  3912  		"getNestedRefNoValidation01": { // fixture index
  3913  			"serverParameter": { // executed template
  3914  				// expected code lines
  3915  				`func NewGetNestedRefNoValidation01Params() GetNestedRefNoValidation01Params {`,
  3916  				`	return GetNestedRefNoValidation01Params{`,
  3917  				`type GetNestedRefNoValidation01Params struct {`,
  3918  				"	HTTPRequest *http.Request `json:\"-\"`",
  3919  				`	NestedRefNovalidation01 map[string]models.NestedRefNoValidation`,
  3920  				`func (o *GetNestedRefNoValidation01Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3921  				`	o.HTTPRequest = r`,
  3922  				`	if runtime.HasBody(r) {`,
  3923  				`		defer r.Body.Close(`,
  3924  				`		var body map[string]models.NestedRefNoValidation`,
  3925  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3926  				`			res = append(res, errors.NewParseError("nestedRefNovalidation01", "body", "", err)`,
  3927  				`		} else {`,
  3928  				`			for k := range body {`,
  3929  				`				if val, ok := body[k]; ok {`,
  3930  				`				if err := val.Validate(route.Formats); err != nil {`,
  3931  				`					break`,
  3932  				`			if len(res) == 0 {`,
  3933  				`				o.NestedRefNovalidation01 = body`,
  3934  				`		return errors.CompositeValidationError(res...`,
  3935  			},
  3936  		},
  3937  		// load expectations for parameters in operation get_nested_ref_no_validation02_parameters.go
  3938  		"getNestedRefNoValidation02": { // fixture index
  3939  			"serverParameter": { // executed template
  3940  				// expected code lines
  3941  				`func NewGetNestedRefNoValidation02Params() GetNestedRefNoValidation02Params {`,
  3942  				`	return GetNestedRefNoValidation02Params{`,
  3943  				`type GetNestedRefNoValidation02Params struct {`,
  3944  				"	HTTPRequest *http.Request `json:\"-\"`",
  3945  				`	NestedRefNovalidation02 map[string]map[string]models.NestedRefNoValidation`,
  3946  				`func (o *GetNestedRefNoValidation02Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3947  				`	o.HTTPRequest = r`,
  3948  				`	if runtime.HasBody(r) {`,
  3949  				`		defer r.Body.Close(`,
  3950  				`		var body map[string]map[string]models.NestedRefNoValidation`,
  3951  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  3952  				`			res = append(res, errors.NewParseError("nestedRefNovalidation02", "body", "", err)`,
  3953  				`		} else {`,
  3954  				`			o.NestedRefNovalidation02 = body`,
  3955  				`			if err := o.validateNestedRefNovalidation02Body(route.Formats); err != nil {`,
  3956  				`		return errors.CompositeValidationError(res...`,
  3957  				`func (o *GetNestedRefNoValidation02Params) validateNestedRefNovalidation02Body(formats strfmt.Registry) error {`,
  3958  				`	nestedRefNovalidation02IC := o.NestedRefNovalidation02`,
  3959  				`	nestedRefNovalidation02IR := make(map[string]map[string]models.NestedRefNoValidation, len(nestedRefNovalidation02IC)`,
  3960  				`	for k, nestedRefNovalidation02IV := range nestedRefNovalidation02IC {`,
  3961  				`		nestedRefNovalidation02IIC := nestedRefNovalidation02IV`,
  3962  				`		nestedRefNovalidation02IIR := make(map[string]models.NestedRefNoValidation, len(nestedRefNovalidation02IIC)`,
  3963  				`		for kk, nestedRefNovalidation02IIV := range nestedRefNovalidation02IIC {`,
  3964  				`			nestedRefNovalidation02II := nestedRefNovalidation02IIV`,
  3965  				`			if err := nestedRefNovalidation02II.Validate(formats); err != nil {`,
  3966  				`				if ve, ok := err.(*errors.Validation); ok {`,
  3967  				`					return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "nestedRefNovalidation02", k), kk)`,
  3968  				`			nestedRefNovalidation02IIR[kk] = nestedRefNovalidation02II`,
  3969  				`		nestedRefNovalidation02IR[k] = nestedRefNovalidation02IIR`,
  3970  				`	o.NestedRefNovalidation02 = nestedRefNovalidation02IR`,
  3971  			},
  3972  		},
  3973  	}
  3974  
  3975  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1536", "fixture-1536-4.yaml"), false, false)
  3976  }
  3977  
  3978  func TestGenParameter_Issue15362_WithExpand(t *testing.T) {
  3979  	log.SetOutput(ioutil.Discard)
  3980  	defer func() {
  3981  		log.SetOutput(os.Stdout)
  3982  	}()
  3983  
  3984  	fixtureConfig := map[string]map[string][]string{
  3985  		// load expectations for parameters in operation get_nested_required_parameters.go
  3986  		"getNestedRequired": { // fixture index
  3987  			"serverParameter": { // executed template
  3988  				// expected code lines
  3989  				`func NewGetNestedRequiredParams() GetNestedRequiredParams {`,
  3990  				`	return GetNestedRequiredParams{`,
  3991  				`type GetNestedRequiredParams struct {`,
  3992  				"	HTTPRequest *http.Request `json:\"-\"`",
  3993  				`	ObjectNestedRequired [][][][]*GetNestedRequiredParamsBodyItems0`,
  3994  				`func (o *GetNestedRequiredParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  3995  				`	o.HTTPRequest = r`,
  3996  				`	if runtime.HasBody(r) {`,
  3997  				`		defer r.Body.Close(`,
  3998  				`		var body [][][][]*GetNestedRequiredParamsBodyItems0`,
  3999  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4000  				`			res = append(res, errors.NewParseError("objectNestedRequired", "body", "", err)`,
  4001  				`		} else {`,
  4002  				`			o.ObjectNestedRequired = body`,
  4003  				`			if err := o.validateObjectNestedRequiredBody(route.Formats); err != nil {`,
  4004  				`		return errors.CompositeValidationError(res...`,
  4005  				`func (o *GetNestedRequiredParams) validateObjectNestedRequiredBody(formats strfmt.Registry) error {`,
  4006  				`	objectNestedRequiredIC := o.ObjectNestedRequired`,
  4007  				`	var objectNestedRequiredIR [][][][]*GetNestedRequiredParamsBodyItems0`,
  4008  				`	for i, objectNestedRequiredIV := range objectNestedRequiredIC {`,
  4009  				`		objectNestedRequiredIIC := objectNestedRequiredIV`,
  4010  				`		if len(objectNestedRequiredIIC) > 0 {`,
  4011  				`			var objectNestedRequiredIIR [][][]*GetNestedRequiredParamsBodyItems0`,
  4012  				`			for ii, objectNestedRequiredIIV := range objectNestedRequiredIIC {`,
  4013  				`				objectNestedRequiredIIIC := objectNestedRequiredIIV`,
  4014  				`				if len(objectNestedRequiredIIIC) > 0 {`,
  4015  				`					var objectNestedRequiredIIIR [][]*GetNestedRequiredParamsBodyItems0`,
  4016  				`					for iii, objectNestedRequiredIIIV := range objectNestedRequiredIIIC {`,
  4017  				`						objectNestedRequiredIIIIC := objectNestedRequiredIIIV`,
  4018  				`						if len(objectNestedRequiredIIIIC) > 0 {`,
  4019  				`							var objectNestedRequiredIIIIR []*GetNestedRequiredParamsBodyItems0`,
  4020  				`							for iiii, objectNestedRequiredIIIIV := range objectNestedRequiredIIIIC {`,
  4021  				`								objectNestedRequiredIIII := objectNestedRequiredIIIIV`,
  4022  				`								if err := objectNestedRequiredIIII.Validate(formats); err != nil {`,
  4023  				`									if ve, ok := err.(*errors.Validation); ok {`,
  4024  				`										return ve.ValidateName(fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", fmt.Sprintf("%s.%v", "objectNestedRequired", i), ii), iii), iiii)`,
  4025  				`								objectNestedRequiredIIIIR = append(objectNestedRequiredIIIIR, objectNestedRequiredIIII`,
  4026  				`							objectNestedRequiredIIIR = append(objectNestedRequiredIIIR, objectNestedRequiredIIIIR`,
  4027  				`					objectNestedRequiredIIR = append(objectNestedRequiredIIR, objectNestedRequiredIIIR`,
  4028  				`			objectNestedRequiredIR = append(objectNestedRequiredIR, objectNestedRequiredIIR`,
  4029  				`	o.ObjectNestedRequired = objectNestedRequiredIR`,
  4030  			},
  4031  			"serverOperation": { // executed template
  4032  				// expected code lines
  4033  				`type GetNestedRequiredParamsBodyItems0 struct {`,
  4034  				"	Pkcs *string `json:\"pkcs\"`",
  4035  				`func (o *GetNestedRequiredParamsBodyItems0) Validate(formats strfmt.Registry) error {`,
  4036  				`	if err := o.validatePkcs(formats); err != nil {`,
  4037  				`		return errors.CompositeValidationError(res...`,
  4038  				`func (o *GetNestedRequiredParamsBodyItems0) validatePkcs(formats strfmt.Registry) error {`,
  4039  				`	if err := validate.Required("pkcs", "body", o.Pkcs); err != nil {`,
  4040  			},
  4041  		},
  4042  	}
  4043  
  4044  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1536", "fixture-1536-2.yaml"), true, false)
  4045  }
  4046  
  4047  func TestGenParameter_Issue1548_base64(t *testing.T) {
  4048  	// testing fixture-1548.yaml with flatten
  4049  	// My App API
  4050  	fixtureConfig := map[string]map[string][]string{
  4051  
  4052  		// load expectations for parameters in operation my_method_parameters.go
  4053  		"MyMethod": { // fixture index
  4054  			"serverParameter": { // executed template
  4055  				// expected code lines
  4056  				`func NewMyMethodParams() MyMethodParams {`,
  4057  				`	return MyMethodParams{`,
  4058  				`type MyMethodParams struct {`,
  4059  				"	HTTPRequest *http.Request `json:\"-\"`",
  4060  				`	ByteInQuery strfmt.Base64`,
  4061  				`	Data strfmt.Base64`,
  4062  				`func (o *MyMethodParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  4063  				`	o.HTTPRequest = r`,
  4064  				`	qs := runtime.Values(r.URL.Query()`,
  4065  				`	qByteInQuery, qhkByteInQuery, _ := qs.GetOK("byteInQuery"`,
  4066  				`	if err := o.bindByteInQuery(qByteInQuery, qhkByteInQuery, route.Formats); err != nil {`,
  4067  				`	if runtime.HasBody(r) {`,
  4068  				`		defer r.Body.Close(`,
  4069  				`		var body strfmt.Base64`,
  4070  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4071  				`			res = append(res, errors.NewParseError("data", "body", "", err)`,
  4072  				`		} else {`,
  4073  				`			o.Data = body`,
  4074  				`			if err := o.validateDataBody(route.Formats); err != nil {`,
  4075  				`		return errors.CompositeValidationError(res...`,
  4076  				`func (o *MyMethodParams) bindByteInQuery(rawData []string, hasKey bool, formats strfmt.Registry) error {`,
  4077  				`	if !hasKey {`,
  4078  				`		return errors.Required("byteInQuery", "query"`,
  4079  				`	var raw string`,
  4080  				`	if len(rawData) > 0 {`,
  4081  				`		raw = rawData[len(rawData)-1]`,
  4082  				`	if err := validate.RequiredString("byteInQuery", "query", raw); err != nil {`,
  4083  				`	value, err := formats.Parse("byte", raw`,
  4084  				`	if err != nil {`,
  4085  				`		return errors.InvalidType("byteInQuery", "query", "strfmt.Base64", raw`,
  4086  				`	o.ByteInQuery = *(value.(*strfmt.Base64)`,
  4087  				`	if err := o.validateByteInQuery(formats); err != nil {`,
  4088  				`func (o *MyMethodParams) validateByteInQuery(formats strfmt.Registry) error {`,
  4089  				`	if err := validate.MaxLength("byteInQuery", "query", o.ByteInQuery.String(), 100); err != nil {`,
  4090  				`func (o *MyMethodParams) validateDataBody(formats strfmt.Registry) error {`,
  4091  			},
  4092  		},
  4093  
  4094  		// load expectations for parameters in operation my_model_method_parameters.go
  4095  		"MyModelMethod": { // fixture index
  4096  			"serverParameter": { // executed template
  4097  				// expected code lines
  4098  				`func NewMyModelMethodParams() MyModelMethodParams {`,
  4099  				`	return MyModelMethodParams{`,
  4100  				`type MyModelMethodParams struct {`,
  4101  				"	HTTPRequest *http.Request `json:\"-\"`",
  4102  				`	Data *models.Base64Model`,
  4103  				`func (o *MyModelMethodParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  4104  				`	o.HTTPRequest = r`,
  4105  				`	if runtime.HasBody(r) {`,
  4106  				`		defer r.Body.Close(`,
  4107  				`		var body models.Base64Model`,
  4108  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4109  				`			res = append(res, errors.NewParseError("data", "body", "", err)`,
  4110  				`		} else {`,
  4111  				`			if err := body.Validate(route.Formats); err != nil {`,
  4112  				`			if len(res) == 0 {`,
  4113  				`				o.Data = &body`,
  4114  				`		return errors.CompositeValidationError(res...`,
  4115  			},
  4116  		},
  4117  	}
  4118  
  4119  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1548", "fixture-1548.yaml"), true, false)
  4120  }
  4121  
  4122  func TestGenParameter_1572(t *testing.T) {
  4123  	log.SetOutput(ioutil.Discard)
  4124  	defer func() {
  4125  		log.SetOutput(os.Stdout)
  4126  	}()
  4127  	// testing fixture-1572.yaml with minimal flatten
  4128  	// edge cases for operations schemas
  4129  
  4130  	/*
  4131  	        Run the following test caes and exercise the minimal flatten mode:
  4132  	   - [x] nil schema in body param / response
  4133  	   - [x] interface{} in body param /response
  4134  	   - [x] additional schema reused from model (body param and response) (with maps or arrays)
  4135  	   - [x] primitive body / response
  4136  	   - [x] $ref'ed response and param (check that minimal flatten expands it)
  4137  
  4138  	*/
  4139  
  4140  	fixtureConfig := map[string]map[string][]string{
  4141  
  4142  		// load expectations for parameters in operation get_interface_parameters.go
  4143  		"getInterface": { // fixture index
  4144  			"serverParameter": { // executed template
  4145  				// expected code lines
  4146  				`func NewGetInterfaceParams() GetInterfaceParams {`,
  4147  				`	return GetInterfaceParams{`,
  4148  				`type GetInterfaceParams struct {`,
  4149  				"	HTTPRequest *http.Request `json:\"-\"`",
  4150  				`	InterfaceBody interface{`,
  4151  				`func (o *GetInterfaceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  4152  				`	o.HTTPRequest = r`,
  4153  				`	if runtime.HasBody(r) {`,
  4154  				`		defer r.Body.Close(`,
  4155  				`		var body interface{`,
  4156  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4157  				`			if err == io.EOF {`,
  4158  				`				res = append(res, errors.Required("interfaceBody", "body")`,
  4159  				`			} else {`,
  4160  				`				res = append(res, errors.NewParseError("interfaceBody", "body", "", err)`,
  4161  				`		} else {`,
  4162  				`			o.InterfaceBody = body`,
  4163  				`	} else {`,
  4164  				`		res = append(res, errors.Required("interfaceBody", "body")`,
  4165  				`		return errors.CompositeValidationError(res...`,
  4166  			},
  4167  		},
  4168  
  4169  		// load expectations for parameters in operation get_null_parameters.go
  4170  		"getNull": { // fixture index
  4171  			"serverParameter": { // executed template
  4172  				// expected code lines
  4173  				`func NewGetNullParams() GetNullParams {`,
  4174  				`	return GetNullParams{`,
  4175  				`type GetNullParams struct {`,
  4176  				"	HTTPRequest *http.Request `json:\"-\"`",
  4177  				`	NullBody interface{`,
  4178  				`func (o *GetNullParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  4179  				`	o.HTTPRequest = r`,
  4180  				`	if runtime.HasBody(r) {`,
  4181  				`		defer r.Body.Close(`,
  4182  				`		var body interface{`,
  4183  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4184  				`			if err == io.EOF {`,
  4185  				`				res = append(res, errors.Required("nullBody", "body")`,
  4186  				`			} else {`,
  4187  				`				res = append(res, errors.NewParseError("nullBody", "body", "", err)`,
  4188  				`		} else {`,
  4189  				`			o.NullBody = body`,
  4190  				`	} else {`,
  4191  				`		res = append(res, errors.Required("nullBody", "body")`,
  4192  				`		return errors.CompositeValidationError(res...`,
  4193  			},
  4194  		},
  4195  
  4196  		// load expectations for parameters in operation get_primitive_parameters.go
  4197  		"getPrimitive": { // fixture index
  4198  			"serverParameter": { // executed template
  4199  				// expected code lines
  4200  				`func NewGetPrimitiveParams() GetPrimitiveParams {`,
  4201  				`	return GetPrimitiveParams{`,
  4202  				`type GetPrimitiveParams struct {`,
  4203  				"	HTTPRequest *http.Request `json:\"-\"`",
  4204  				`	PrimitiveBody uint32`,
  4205  				`func (o *GetPrimitiveParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  4206  				`	o.HTTPRequest = r`,
  4207  				`	if runtime.HasBody(r) {`,
  4208  				`		defer r.Body.Close(`,
  4209  				`		var body uint32`,
  4210  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4211  				`			if err == io.EOF {`,
  4212  				`				res = append(res, errors.Required("primitiveBody", "body")`,
  4213  				`			} else {`,
  4214  				`				res = append(res, errors.NewParseError("primitiveBody", "body", "", err)`,
  4215  				`		} else {`,
  4216  				`			o.PrimitiveBody = body`,
  4217  				`			if err := o.validatePrimitiveBodyBody(route.Formats); err != nil {`,
  4218  				`	} else {`,
  4219  				`		res = append(res, errors.Required("primitiveBody", "body")`,
  4220  				`		return errors.CompositeValidationError(res...`,
  4221  				`func (o *GetPrimitiveParams) validatePrimitiveBodyBody(formats strfmt.Registry) error {`,
  4222  				`	if err := validate.MaximumInt("primitiveBody", "body", int64(o.PrimitiveBody), 100, false); err != nil {`,
  4223  			},
  4224  		},
  4225  
  4226  		// load expectations for parameters in operation get_model_interface_parameters.go
  4227  		"getModelInterface": { // fixture index
  4228  			"serverParameter": { // executed template
  4229  				// expected code lines
  4230  				`func NewGetModelInterfaceParams() GetModelInterfaceParams {`,
  4231  				`	return GetModelInterfaceParams{`,
  4232  				`type GetModelInterfaceParams struct {`,
  4233  				"	HTTPRequest *http.Request `json:\"-\"`",
  4234  				`	InterfaceBody map[string]models.ModelInterface`,
  4235  				`func (o *GetModelInterfaceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {`,
  4236  				`	o.HTTPRequest = r`,
  4237  				`	if runtime.HasBody(r) {`,
  4238  				`		defer r.Body.Close(`,
  4239  				`		var body map[string]models.ModelInterface`,
  4240  				`		if err := route.Consumer.Consume(r.Body, &body); err != nil {`,
  4241  				`			if err == io.EOF {`,
  4242  				`				res = append(res, errors.Required("interfaceBody", "body")`,
  4243  				`			} else {`,
  4244  				`				res = append(res, errors.NewParseError("interfaceBody", "body", "", err)`,
  4245  				`		} else {`,
  4246  				`			o.InterfaceBody = body`,
  4247  				`	} else {`,
  4248  				`		res = append(res, errors.Required("interfaceBody", "body")`,
  4249  				`		return errors.CompositeValidationError(res...`,
  4250  			},
  4251  		},
  4252  	}
  4253  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "enhancements", "1572", "fixture-1572.yaml"), true, false)
  4254  }
  4255  
  4256  func TestGenParameter_1637(t *testing.T) {
  4257  	log.SetOutput(ioutil.Discard)
  4258  	defer func() {
  4259  		log.SetOutput(os.Stdout)
  4260  	}()
  4261  	// testing fixture-1637.yaml with minimal flatten
  4262  	// slice of polymorphic type in body param
  4263  
  4264  	fixtureConfig := map[string]map[string][]string{
  4265  
  4266  		// load expectations for parameters
  4267  		"test": { // fixture index
  4268  			"serverParameter": { // executed template
  4269  				`body, err := models.UnmarshalValueSlice(r.Body, route.Consumer)`,
  4270  			},
  4271  		},
  4272  	}
  4273  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1637", "fixture-1637.yaml"), true, false)
  4274  }
  4275  
  4276  func TestGenParameter_1755(t *testing.T) {
  4277  	log.SetOutput(ioutil.Discard)
  4278  	defer func() {
  4279  		log.SetOutput(os.Stdout)
  4280  	}()
  4281  	// testing fixture-1755.yaml with minimal flatten
  4282  	// body param is array with slice validation (e.g. minItems): initialize array with body
  4283  
  4284  	fixtureConfig := map[string]map[string][]string{
  4285  
  4286  		// load expectations for parameters
  4287  		"registerAsset": { // fixture index
  4288  			"serverParameter": { // executed template
  4289  				`o.AssetProperties = body`,
  4290  				`assetPropertiesSize := int64(len(o.AssetProperties))`,
  4291  			},
  4292  		},
  4293  	}
  4294  	assertParams(t, fixtureConfig, filepath.Join("..", "fixtures", "bugs", "1755", "fixture-1755.yaml"), true, false)
  4295  }