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