Skip to content

Commit f576f05

Browse files
authored
Fix Rust generation for versions without minor or patch parts (OpenAPITools#19946)
This fixes generation of a Rust library for OpenAPI specifications where `info.version` was a single-digit number. This happened to for [this](https://github.com/motis-project/motis/blob/db005f2e55812b8231e2e2dbac4d3abf711a8610/openapi.yaml#L10) specification. The fix for this issue is similar to the one in !17440.
1 parent e9c3c63 commit f576f05

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,12 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
422422
content = content.trim().replace("v", "");
423423
content = content.replace("V", "");
424424

425-
// convert 5.2 to 5.2.0 for example
426425
String[] contents = content.split("[.]");
427-
if (contents.length == 2) {
426+
if (contents.length == 1) {
427+
// convert 5 to 5.0.0 for example
428+
content += ".0.0";
429+
} else if (contents.length == 2) {
430+
// convert 5.2 to 5.2.0 for example
428431
content += ".0";
429432
}
430433

0 commit comments

Comments
 (0)