func TestTypeResolver_TupleTypes(t *testing.T) {
	_, resolver, err := basicTaskListResolver(t)
	if assert.NoError(t, err) {
		// tuple type (items with multiple schemas)
		parent := new(spec.Schema)
		parent.Typed("array", "")
		parent.Items = new(spec.SchemaOrArray)
		parent.Items.Schemas = append(
			parent.Items.Schemas,
			*spec.StringProperty(),
			*spec.Int64Property(),
			*spec.Float64Property(),
			*spec.BoolProperty(),
			*spec.ArrayProperty(spec.StringProperty()),
			*spec.RefProperty("#/definitions/Comment"),
		)

		rt, err := resolver.ResolveSchema(parent, true, true)
		if assert.NoError(t, err) {
			assert.False(t, rt.IsArray)
			assert.True(t, rt.IsTuple)
		}
	}
}
示例#2
0
	"net/http"
	"net/http/httptest"

	"github.com/go-openapi/spec"
	"github.com/stretchr/testify/assert"
)

var knownSchemas = []*spec.Schema{
	spec.BoolProperty(),                  // 0
	spec.StringProperty(),                // 1
	spec.Int8Property(),                  // 2
	spec.Int16Property(),                 // 3
	spec.Int32Property(),                 // 4
	spec.Int64Property(),                 // 5
	spec.Float32Property(),               // 6
	spec.Float64Property(),               // 7
	spec.DateProperty(),                  // 8
	spec.DateTimeProperty(),              // 9
	(&spec.Schema{}),                     // 10
	(&spec.Schema{}).Typed("object", ""), // 11
	(&spec.Schema{}).Typed("", ""),       // 12
	(&spec.Schema{}).Typed("", "uuid"),   // 13
}

func newCObj() *spec.Schema {
	return (&spec.Schema{}).Typed("object", "").SetProperty("id", *spec.Int64Property())
}

var complexObject = newCObj()

var complexSchemas = []*spec.Schema{