Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions providers/openapi/schema/parse_xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func parseValue(s string, ref *Schema) (interface{}, error) {
t := ref.Type

if t.IsInteger() {
v, err := strconv.Atoi(s)
val64, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return nil, fmt.Errorf("parse integer failed: %v", s)
}
return v, nil
return val64, nil
}

if t.IsNumber() {
Expand Down
10 changes: 5 additions & 5 deletions providers/openapi/schema/parse_xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestUnmarshalXML(t *testing.T) {
test: func(t *testing.T) {
v, err := schema.UnmarshalXML(strings.NewReader("<year>2005</year>"), schematest.New("integer"))
require.NoError(t, err)
require.Equal(t, 2005, v)
require.Equal(t, int64(2005), v)
},
},
{
Expand Down Expand Up @@ -229,7 +229,7 @@ func TestUnmarshalXML(t *testing.T) {
),
))
require.NoError(t, err)
require.Equal(t, map[string]interface{}{"foo": 123, "yuh": "bar"}, v)
require.Equal(t, map[string]interface{}{"foo": int64(123), "yuh": "bar"}, v)
},
},
{
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestUnmarshalXML(t *testing.T) {
),
)
require.NoError(t, err)
require.Equal(t, map[string]interface{}{"id": 15, "author": "J K. Rowling", "title": "Harry Potter", "smp": "https://example.com/schema"}, v)
require.Equal(t, map[string]interface{}{"id": int64(15), "author": "J K. Rowling", "title": "Harry Potter", "smp": "https://example.com/schema"}, v)
},
},
{
Expand Down Expand Up @@ -413,7 +413,7 @@ func TestUnmarshalXML_Old(t *testing.T) {
schematest.WithProperty("author", schematest.New("string"))),
test: func(t *testing.T, i interface{}, err error) {
require.NoError(t, err)
require.Equal(t, map[string]interface{}{"id": 0, "title": "foo", "author": "bar"}, i)
require.Equal(t, map[string]interface{}{"id": int64(0), "title": "foo", "author": "bar"}, i)
},
},
{
Expand All @@ -426,7 +426,7 @@ func TestUnmarshalXML_Old(t *testing.T) {
schematest.WithProperty("author", schematest.New("string", schematest.WithXml(&schema.Xml{Name: "Author"})))),
test: func(t *testing.T, i interface{}, err error) {
require.NoError(t, err)
require.Equal(t, map[string]interface{}{"id": 0, "title": "foo", "author": "bar"}, i)
require.Equal(t, map[string]interface{}{"id": int64(0), "title": "foo", "author": "bar"}, i)
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions schema/json/parser/parser_integer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func (p *Parser) ParseInteger(i interface{}, s *schema.Schema) (interface{}, err
}
switch s.Format {
case "int32":
n32, err := strconv.Atoi(v)
val64, err := strconv.ParseInt(v, 10, 32)
if err != nil {
return 0, &ErrorDetail{
Message: fmt.Sprintf("invalid type, expected %v but got %v", s.Type, toType(i)),
Field: "type",
}
}
n = int64(n32)
n = val64
default:
var err error
n, err = strconv.ParseInt(v, 10, 64)
Expand Down
Loading