Bug Report Checklist
Description
If there is no title, the rust generator tries to derive a meaningful name from the type (see #17896). However, this fails in some cases, for example if there is a oneOf with multiple arrays inside.
The OpenAPI spec below produces the following enum:
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Option1OrOption2Options {
Array(Vec<String>),
Array(Vec<i32>),
}
This cannot be compiled, the error message is error[E0428]: the name 'Array' is defined multiple times. I would expect that all code generated from a valid OpenAPI spec generates compilable rust code.
openapi-generator version
I tested with version 06ed7c8 (the current main).
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: oneOf with arrays
description: Ensure different names for kinds in enum when using oneOf with arrays.
version: 1.0.0
paths: {}
components:
schemas:
Option1OrOption2:
type: object
properties:
Options:
oneOf:
- type: array
items:
type: string
- type: array
items:
type: integer
Steps to reproduce
I'll provide the steps to create a failing test using the valid OpenAPI spec above.
-
Add the snippet above to the test resources (e.g. modules/openapi-generator/src/test/resources/3_0/rust/oneof-with-arrays.yaml).
-
Create a config for the test (e.g. bin/configs/rust-reqwest-oneOf-with-arrays.yaml):
generatorName: rust
outputDir: samples/client/others/rust/reqwest/oneOf-with-arrays
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/oneof-with-arrays.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: oneof-with-arrays-reqwest
-
Generate the rust samples with ./bin/generate-samples.sh ./bin/configs/rust-*.
-
Execute the tests with mvn integration-test -f samples/client/others/rust/pom.xml.
Related issues/PRs
Suggest a fix
I'm new to rust and to openapi-generator, so I am no help here, sorry.
Bug Report Checklist
Description
If there is no
title, the rust generator tries to derive a meaningful name from the type (see #17896). However, this fails in some cases, for example if there is aoneOfwith multiple arrays inside.The OpenAPI spec below produces the following enum:
This cannot be compiled, the error message is
error[E0428]: the name 'Array' is defined multiple times. I would expect that all code generated from a valid OpenAPI spec generates compilable rust code.openapi-generator version
I tested with version 06ed7c8 (the current main).
OpenAPI declaration file content or url
Steps to reproduce
I'll provide the steps to create a failing test using the valid OpenAPI spec above.
Add the snippet above to the test resources (e.g.
modules/openapi-generator/src/test/resources/3_0/rust/oneof-with-arrays.yaml).Create a config for the test (e.g.
bin/configs/rust-reqwest-oneOf-with-arrays.yaml):Generate the rust samples with
./bin/generate-samples.sh ./bin/configs/rust-*.Execute the tests with
mvn integration-test -f samples/client/others/rust/pom.xml.Related issues/PRs
oneOfgeneration for client #17915 solving [BUG][Rust] oneOf with array produces invalid code #17896.oneOftypes (Rust Server) #17210 is a follow up issue but it's different from the issue I am opening here.Suggest a fix
I'm new to rust and to openapi-generator, so I am no help here, sorry.