diff --git a/codegenerator/rust_cli.py b/codegenerator/rust_cli.py index 21d1d23..2e5d8c0 100644 --- a/codegenerator/rust_cli.py +++ b/codegenerator/rust_cli.py @@ -250,7 +250,7 @@ class StructFieldResponse(common_rust.StructField): operation_type: str, ): macros = set() - if self.is_optional: + if self.is_optional or self.data_type.type_hint.startswith("Option<"): macros.add("optional") if self.local_name != self.remote_name: macros.add(f'title="{self.remote_name}"') diff --git a/codegenerator/tests/unit/test_rust_cli.py b/codegenerator/tests/unit/test_rust_cli.py index c24213d..dcd3c37 100644 --- a/codegenerator/tests/unit/test_rust_cli.py +++ b/codegenerator/tests/unit/test_rust_cli.py @@ -37,7 +37,7 @@ struct ResponseData { /// aoaos /// #[serde()] - #[structable(pretty)] + #[structable(optional,pretty)] foo: Option<Value>, } """ diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 943b0c5..69b9574 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -8,8 +8,7 @@ - openstack-tox-py311 - codegenerator-openapi-baremetal-tips-with-api-ref - codegenerator-openapi-block-storage-tips-with-api-ref - - codegenerator-openapi-compute-tips-with-api-ref: - voting: false + - codegenerator-openapi-compute-tips-with-api-ref - codegenerator-openapi-dns-tips-with-api-ref - codegenerator-openapi-identity-tips-with-api-ref - codegenerator-openapi-image-tips-with-api-ref @@ -26,8 +25,7 @@ - openstack-tox-py311 - codegenerator-openapi-baremetal-tips-with-api-ref - codegenerator-openapi-block-storage-tips-with-api-ref - - codegenerator-openapi-compute-tips-with-api-ref: - voting: false + - codegenerator-openapi-compute-tips-with-api-ref - codegenerator-openapi-dns-tips-with-api-ref - codegenerator-openapi-identity-tips-with-api-ref - codegenerator-openapi-image-tips-with-api-ref diff --git a/zuul.d/rust.yaml b/zuul.d/rust.yaml index b84c0a1..6fab1a4 100644 --- a/zuul.d/rust.yaml +++ b/zuul.d/rust.yaml @@ -53,8 +53,8 @@ dependencies: - name: codegenerator-openapi-block-storage-tips-with-api-ref soft: true - # - name: codegenerator-openapi-compute-tips-with-api-ref - # soft: true + - name: codegenerator-openapi-compute-tips-with-api-ref + soft: true - name: codegenerator-openapi-dns-tips-with-api-ref soft: true - name: codegenerator-openapi-identity-tips-with-api-ref