From cc2410683278be4d9b731d9a6ac02ceb7dae503a Mon Sep 17 00:00:00 2001 From: Emily Crandall Fleischman <120736736+emilycf-cw@users.noreply.github.com> Date: Sat, 15 Jun 2024 06:12:38 -0400 Subject: [PATCH] [Rust-Axum] Use x-response-id if specified (#18906) * [Rust-Axum] Use x-response-id if specified * update samples --- .../languages/RustAxumServerCodegen.java | 20 ++++++++++--------- .../multipart-v3/.openapi-generator/VERSION | 2 +- .../rust-axum/output/multipart-v3/README.md | 2 +- .../openapi-v3/.openapi-generator/VERSION | 2 +- .../rust-axum/output/openapi-v3/README.md | 2 +- .../output/ops-v3/.openapi-generator/VERSION | 2 +- .../rust-axum/output/ops-v3/README.md | 2 +- .../.openapi-generator/VERSION | 2 +- .../README.md | 2 +- .../petstore/.openapi-generator/VERSION | 2 +- .../rust-axum/output/petstore/README.md | 2 +- .../.openapi-generator/VERSION | 2 +- .../output/ping-bearer-auth/README.md | 2 +- .../.openapi-generator/VERSION | 2 +- .../output/rust-axum-header-uuid/README.md | 2 +- .../rust-axum-test/.openapi-generator/VERSION | 2 +- .../rust-axum/output/rust-axum-test/README.md | 2 +- .../.openapi-generator/VERSION | 2 +- .../rust-axum-validation-test/README.md | 2 +- 19 files changed, 29 insertions(+), 27 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java index 9f8475eb20f..6cef19c836f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java @@ -475,16 +475,18 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege original = operation.getResponses().get(rsp.code); } - // Create a unique responseID for this response. - String[] words = rsp.message.split("[^A-Za-z ]"); + // Create a unique responseID for this response, if one is not already specified with the "x-response-id" extension + if (!rsp.vendorExtensions.containsKey("x-response-id")) { + String[] words = rsp.message.split("[^A-Za-z ]"); - // build responseId from both status code and description - String responseId = "Status" + rsp.code + ( - ((words.length != 0) && (!words[0].trim().isEmpty())) ? - "_" + camelize(words[0].replace(" ", "_")) : "" - ); - - rsp.vendorExtensions.put("x-response-id", responseId); + // build responseId from both status code and description + String responseId = "Status" + rsp.code + ( + ((words.length != 0) && (!words[0].trim().isEmpty())) ? + "_" + camelize(words[0].replace(" ", "_")) : "" + ); + rsp.vendorExtensions.put("x-response-id", responseId); + } + if (rsp.dataType != null) { // Get the mimetype which is produced by this response. Note // that although in general responses produces a set of diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/README.md b/samples/server/petstore/rust-axum/output/multipart-v3/README.md index 68f1c75bf6c..72b7f696506 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/README.md +++ b/samples/server/petstore/rust-axum/output/multipart-v3/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.7 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/README.md b/samples/server/petstore/rust-axum/output/openapi-v3/README.md index 20b9a33bcac..17d0e3c07b2 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-axum/output/openapi-v3/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.7 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/ops-v3/README.md b/samples/server/petstore/rust-axum/output/ops-v3/README.md index 9be673f9440..90792c9ce7c 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/README.md +++ b/samples/server/petstore/rust-axum/output/ops-v3/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.0.1 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md index 69a87cb8bb1..a2e1c2ad4cb 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.0 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore/README.md b/samples/server/petstore/rust-axum/output/petstore/README.md index a6f7c5cb19a..c6dc92709b7 100644 --- a/samples/server/petstore/rust-axum/output/petstore/README.md +++ b/samples/server/petstore/rust-axum/output/petstore/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.0 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md b/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md index 49a2490640c..01b4c91fa03 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md index e99c9e7847f..b26f35abd83 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.1.9 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-test/README.md index 615ce4f4c74..4f4f5774baa 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 2.3.4 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION index ecb21862b1e..7e7b8b9bc73 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0-SNAPSHOT +7.7.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md index a017ed146e0..e0e8006366b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.0.1 -- Generator version: 7.6.0-SNAPSHOT +- Generator version: 7.7.0-SNAPSHOT