From 3cd40046f0291d7c667b64faa4b3edd523384b8a Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Wed, 10 Sep 2025 20:54:57 +0200 Subject: [PATCH] Default to u32 when maximum is unset Few object-store parameters set the format int64 and minimum to 0. Latest changes in the format handling result in u32 params in the generated code. Change the login to default at u32 when format is not specified, but u64 when int64 with min is specified. Additionally improve mentioned object-store schemas. Change-Id: I99f70526f2015beefe43950330b27c564688a69f Signed-off-by: Artem Goncharov --- codegenerator/common/rust.py | 14 +++++-- static/openapi_specs/object-store/v1.yaml | 47 ++++++++++++++++------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/codegenerator/common/rust.py b/codegenerator/common/rust.py index e200bed..9fefa91 100644 --- a/codegenerator/common/rust.py +++ b/codegenerator/common/rust.py @@ -89,11 +89,19 @@ class Integer(BasePrimitiveType): def type_hint(self): if self.minimum is not None: if self.minimum == 0: - if not self.maximum or self.format == "u32": + if self.format in ["u64", "uint64"]: + # Do not default at u64 (for now), unless explicitly + # requested. + return "u64" + elif ( + not self.maximum + or self.maximum == 4294967295 + or self.format in ["u32", "uint32"] + ): return "u32" - elif self.maximum == 65535 or self.format == "u16": + elif self.maximum == 65535 or self.format in ["u16", "uint16"]: return "u16" - elif self.maximum == 255 or self.format == "u8": + elif self.maximum == 255 or self.format == ["u8", "uint8"]: return "u8" elif self.minimum == -128 and self.maximum == 127: return "i8" diff --git a/static/openapi_specs/object-store/v1.yaml b/static/openapi_specs/object-store/v1.yaml index 273d782..afcecdf 100644 --- a/static/openapi_specs/object-store/v1.yaml +++ b/static/openapi_specs/object-store/v1.yaml @@ -695,40 +695,48 @@ components: The total number of bytes that are stored in Object Storage for the account. schema: type: integer - format: int64 + format: uint64 + minimum: 0 X-Account-Container-Count: description: The number of containers. schema: type: integer - format: int64 + format: uint64 + minimum: 0 X-Account-Object-Count: description: The number of objects in the account. schema: type: integer - format: int64 + format: uint64 + minimum: 0 X-Account-Storage-Policy-Bytes-Used: description: | The total number of bytes that are stored in in a given storage policy, where name is the name of the storage policy. schema: type: integer + format: uint64 + minimum: 0 X-Account-Storage-Policy-Container-Count: description: | The number of containers in the account that use the given storage policy where name is the name of the storage policy. schema: type: integer - format: int64 + format: uint64 + minimum: 0 X-Account-Storage-Policy-Object-Count: description: | The number of objects in given storage policy where name is the name of the storage policy. schema: type: integer format: int64 + minimum: 0 X-Account-Meta-Quota-Bytes: description: | If present, this is the limit on the total size in bytes of objects stored in the account. Typically this value is set by an administrator. schema: - type: string + type: integer format: int64 + minimum: 0 X-Account-Access-Control: description: | Note: X-Account-Access-Control is not supported by Keystone auth. @@ -749,11 +757,13 @@ components: schema: type: integer format: int64 + minimum: 0 X-Container-Object-Count: description: The number of objects. schema: type: integer format: int64 + minimum: 0 acceptRanges: description: The type of ranges that the object accepts. schema: @@ -772,12 +782,16 @@ components: description: | The maximum object count of the container. If not set, this header is not returned by this operation. schema: - type: string + type: integer + format: uint64 + minimum: 0 X-Container-Meta-Quota-Bytes: description: | The maximum size of the container, in bytes. If not set, this header is not returned by this operation. schema: - type: string + type: integer + format: uint64 + minimum: 0 X-Storage-Policy: description: | In requests, specifies the name of the storage policy to use for the container. In responses, is the storage policy name. The storage policy of the container cannot be changed. @@ -1054,7 +1068,8 @@ components: description: | Maximum time for the origin to hold the preflight results. A browser may make an OPTIONS call to verify the origin is allowed to make the request. Set the value to an integer number of seconds after the time that the request was received. schema: - type: string + type: integer + format: uint64 X-Container-Meta-Access-Control-Expose-Headers: in: header name: X-Container-Meta-Access-Control-Expose-Headers @@ -1076,14 +1091,18 @@ components: description: | Sets maximum size of the container, in bytes. Typically these values are set by an administrator. Returns a 413 response (request entity too large) when an object PUT operation exceeds this quota value. This value does not take effect immediately. see Container Quotas for more information. schema: - type: string + type: integer + format: uint64 + minimum: 0 X-Container-Meta-Quota-Count: in: header name: X-Container-Meta-Quota-Count description: | Sets maximum object count of the container. Typically these values are set by an administrator. Returns a 413 response (request entity too large) when an object PUT operation exceeds this quota value. This value does not take effect immediately. see Container Quotas for more information. schema: - type: string + type: integer + format: uint64 + minimum: 0 X-Container-Meta-Temp-Url-Key: in: header name: X-Container-Meta-Temp-URL-Key @@ -1123,6 +1142,8 @@ components: description: For an integer value n, limits the number of results to n. schema: type: integer + format: uint32 + minimum: 0 marker: in: query name: marker @@ -1354,13 +1375,13 @@ components: count: description: The number of objects in the container. type: integer - format: int64 + format: uint64 minimum: 0 bytes: description: | The total number of bytes that are stored in Object Storage for the account. type: integer - format: int64 + format: uint64 minimum: 0 name: description: The name of the container. @@ -1386,7 +1407,7 @@ components: description: | The total number of bytes that are stored in Object Storage for the container. type: integer - format: int64 + format: uint64 minimum: 0 hash: description: The MD5 checksum value of the object content.