Fix some typos in type formats comparison

Change-Id: Ie23e1d3b12e2dd11e308e706ca68f93a98908c7f
Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com>
This commit is contained in:
Artem Goncharov
2025年09月10日 17:51:53 +02:00
parent 3ac21566ce
commit 99fb44a5b3

View File

@@ -100,26 +100,26 @@ class Integer(BasePrimitiveType):
elif self.minimum == -32768 and self.maximum == 32767:
return "i8"
if self.format in ["int32", "i32"]:
return "i32"
elif self.format == ["int16", "i16"]:
return "i16"
elif self.format == ["int8", "i8"]:
return "i8"
elif self.format == ["uint32", "u32"]:
return "u32"
elif self.format == ["uint16", "u16"]:
return "u16"
elif self.format == ["uint8", "u8"]:
return "u8"
elif self.format == ["int64", "i64"]:
if self.format in ["int64", "i64"]:
return "i64"
elif self.format == ["uint64", "u64"]:
elif self.format in ["int32", "i32"]:
return "i32"
elif self.format in ["int16", "i16"]:
return "i16"
elif self.format in ["int8", "i8"]:
return "i8"
elif self.format in ["uint64", "u64"]:
return "u64"
elif self.format in ["uint32", "u32"]:
return "u32"
elif self.format in ["uint16", "u16"]:
return "u16"
elif self.format in ["uint8", "u8"]:
return "u8"
return "i32"
def get_sample(self):
return f"7 as {self.type_hint}" if self.type_hint != "i32" else "123"
return f"7_{self.type_hint}" if self.type_hint != "i32" else "123"
class Null(BasePrimitiveType):

View File

@@ -224,3 +224,31 @@ pub struct Request<'a> {
type_model = parser.parse_schema(schema, [])
rust_type = rust_sdk.TypeManager().convert_model(type_model)
self.assertEqual("u8", rust_type.type_hint)
def test_type_i64(self):
schema = {"type": "integer", "format": "int64"}
parser = model.JsonSchemaParser()
type_model = parser.parse_schema(schema, [])
rust_type = rust_sdk.TypeManager().convert_model(type_model)
self.assertEqual("i64", rust_type.type_hint)
def test_type_i32(self):
schema = {"type": "integer", "format": "int32"}
parser = model.JsonSchemaParser()
type_model = parser.parse_schema(schema, [])
rust_type = rust_sdk.TypeManager().convert_model(type_model)
self.assertEqual("i32", rust_type.type_hint)
def test_type_i16(self):
schema = {"type": "integer", "format": "int16"}
parser = model.JsonSchemaParser()
type_model = parser.parse_schema(schema, [])
rust_type = rust_sdk.TypeManager().convert_model(type_model)
self.assertEqual("i16", rust_type.type_hint)
def test_type_i8(self):
schema = {"type": "integer", "format": "i8"}
parser = model.JsonSchemaParser()
type_model = parser.parse_schema(schema, [])
rust_type = rust_sdk.TypeManager().convert_model(type_model)
self.assertEqual("i8", rust_type.type_hint)
Reference in New Issue
openstack/codegenerator
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.