Fix Rust generation for versions without minor or patch parts (#19946)

This fixes generation of a Rust library for OpenAPI specifications
where `info.version` was a single-digit number. This happened to for
[this](db005f2e55/openapi.yaml (L10))
specification. The fix for this issue is similar to the one in !17440.
This commit is contained in:
Schmiddiii 2024-10-23 08:35:37 +02:00 committed by GitHub
parent e9c3c63732
commit f576f05eb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -422,9 +422,12 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
content = content.trim().replace("v", "");
content = content.replace("V", "");
// convert 5.2 to 5.2.0 for example
String[] contents = content.split("[.]");
if (contents.length == 2) {
if (contents.length == 1) {
// convert 5 to 5.0.0 for example
content += ".0.0";
} else if (contents.length == 2) {
// convert 5.2 to 5.2.0 for example
content += ".0";
}