func TestSchemaFromMapWithUnsupportedKeys(t *testing.T) {
	g := gen(t)
	schema := g.newSchemaFromType(rt(map[int]string{}))
	assert.Nil(t, schema)
	assert.Len(t, g.Errors(), 1)
	assert.Implements(t, (*error)(nil), g.Errors()[0])
	assert.NotEmpty(t, g.Errors()[0].Error())
}
TestSchemaFromMapWithUnsupportedKeys tests that a
schema cannot be created given a map type with
unsupported key's type.
package openapi
import (
	"encoding/json"
	"io/ioutil"
	"math"
	"reflect"
	"testing"
	"time"
	"github.com/Pallinder/go-randomdata"
	"github.com/loopfz/gadgeto/tonic"
	"github.com/stretchr/testify/assert"
)
var genConfig = &SpecGenConfig{
	ValidatorTag:      tonic.ValidationTag,
	PathLocationTag:   tonic.PathTag,
	QueryLocationTag:  tonic.QueryTag,
	HeaderLocationTag: tonic.HeaderTag,
	EnumTag:           tonic.EnumTag,
	DefaultTag:        tonic.DefaultTag,
}
var rt = reflect.TypeOf
type (
	W struct {
		A, B string
	}
	u struct {
		S int
	}
	q int
	X struct {
		*X  
		*Y
		A string `validate:"required"`
		B *int
		C bool `deprecated:"true"`
		D []*Y
		E [3]*X
		F *X
		G *Y
		H map[int]*Y  
		*u
		uu *u  
		q      
	}
	Y struct {
		H float32   `validate:"required"`
		I time.Time `format:"date"`
		J *uint8    `deprecated:"oui"`  
		K *Z        `validate:"required"`
		N struct {
			Na, Nb string
			Nc     time.Duration
		}
		l int  
		M int `json:"-"`
	}
	Z map[string]*Y
)
func (*X) TypeName() string { return "XXX" }
func (*W) Format() string   { return "wallet" }
func (*W) Type() string     { return "string" }
func TestStructFieldName(t *testing.T) {
	type T struct {
		A  string `name:"A"`
		Ba string `name:""`
		AB string `name:"-"`
		B  struct{}
	}
	to := reflect.TypeOf(T{})
	assert.Equal(t, "A", fieldNameFromTag(to.Field(0), "name"))
	assert.Equal(t, "Ba", fieldNameFromTag(to.Field(1), "name"))
	assert.Equal(t, "", fieldNameFromTag(to.Field(2), "name"))
}
func TestAddTag(t *testing.T) {
	g := gen(t)
	g.api.Tags = append(g.api.Tags, nil)
	g.AddTag("", "Test routes")
	assert.Len(t, g.API().Tags, 1)
	g.AddTag("Test", "Test routes")
	assert.Len(t, g.API().Tags, 2)
	tag := g.API().Tags[1]
	assert.NotNil(t, tag)
	assert.Equal(t, tag.Name, "Test")
	assert.Equal(t, tag.Description, "Test routes")
	g.AddTag("Test", "Routes test")
	assert.Equal(t, tag.Description, "Routes test")
	g.AddTag("A", "")
	assert.Len(t, g.API().Tags, 3)
	tag = g.API().Tags[1]
	assert.Equal(t, "A", tag.Name)
}
func TestSchemaFromPrimitiveType(t *testing.T) {
	g := gen(t)
	schema := g.newSchemaFromType(rt(new(int64)))
	if schema.Schema == nil {
		t.Error("expected an inlined schema, got a schema reference")
	}
	assert.Equal(t, "integer", schema.Type)
	assert.Equal(t, "int64", schema.Format)
	assert.True(t, schema.Nullable)
}
func TestSchemaFromInterface(t *testing.T) {
	g := gen(t)
	schema := g.newSchemaFromType(tofEmptyInterface)
	assert.NotNil(t, schema)
	assert.Empty(t, schema.Type)
	assert.Empty(t, schema.Format)
	assert.True(t, schema.Nullable)
	assert.NotEmpty(t, schema.Description)
}
func TestSchemaFromUnsupportedType(t *testing.T) {
	g := gen(t)
	schema := g.newSchemaFromType(nil)
	assert.Nil(t, schema)
	schema = g.newSchemaFromType(rt(func() {}))
	assert.Nil(t, schema)
	assert.Len(t, g.Errors(), 1)
	assert.Implements(t, (*error)(nil), g.Errors()[0])
	assert.NotEmpty(t, g.Errors()[0])
}