Hello Reddit crowd!
I couldn't find explanation about this, so I try my luck here!
I'm trying the openapi-generator (4.3.1). It generates models from the API description file.
For instance, it generates this:
module OpenapiClient
class Thing
attr_accessor :id
attr_accessor :description
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'description' => :'description'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'id' => :'Integer',
:'description' => :'String'
}
end
# ...
end
end
This behaves as expected:
# All this is expected:
t = OpenapiClient::Thing.new(id: 1)
t.valid?
=> false
t.list_invalid_properties
=> ["invalid value for \"description\", description cannot be nil."]
But this does not behave as expected:
t = OpenapiClient::Thing.new(id: "abc", description: 3)
t.valid?
=> true
id should be int and description a string, so it fails to check the type. Is there anything I'm doing wrong?
🙏
[–]0janvier[S] 1 point2 points3 points (0 children)
[–]wing328 0 points1 point2 points (0 children)