mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 08:30:56 +00:00
[Rust Server] Flag responses as must use (#5559)
* [Rust Server] Flag responses as must use if there is more than a single option * Update samples
This commit is contained in:
parent
806562bb05
commit
15a2390fe5
@ -716,6 +716,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
op.vendorExtensions.put("PATH_ID", pathId);
|
||||
op.vendorExtensions.put("hasPathParams", hasPathParams);
|
||||
op.vendorExtensions.put("HttpMethod", op.httpMethod.toUpperCase(Locale.ROOT));
|
||||
|
||||
if (!op.vendorExtensions.containsKey("x-mustUseResponse")) {
|
||||
// If there's more than one response, than by default the user must explicitly handle them
|
||||
op.vendorExtensions.put("x-mustUseResponse", op.responses.size() > 1);
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.allParams) {
|
||||
processParam(param, op);
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
#[derive(Debug, PartialEq)]
|
||||
{{#vendorExtensions.x-mustUseResponse}}
|
||||
#[must_use]
|
||||
{{/vendorExtensions.x-mustUseResponse}}
|
||||
pub enum {{{operationId}}}Response {
|
||||
{{#responses}}
|
||||
{{#message}}
|
||||
|
@ -93,6 +93,7 @@ pub enum MergePatchJsonGetResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum MultigetGetResponse {
|
||||
/// JSON rsp
|
||||
JSONRsp
|
||||
@ -155,6 +156,7 @@ pub enum RequiredOctetStreamPutResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum ResponsesWithHeadersGetResponse {
|
||||
/// Success
|
||||
Success
|
||||
@ -173,6 +175,7 @@ pub enum ResponsesWithHeadersGetResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum Rfc7807GetResponse {
|
||||
/// OK
|
||||
OK
|
||||
@ -201,6 +204,7 @@ pub enum UuidGetResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum XmlExtraPostResponse {
|
||||
/// OK
|
||||
OK
|
||||
@ -210,6 +214,7 @@ pub enum XmlExtraPostResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum XmlOtherPostResponse {
|
||||
/// OK
|
||||
OK
|
||||
@ -219,6 +224,7 @@ pub enum XmlOtherPostResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum XmlOtherPutResponse {
|
||||
/// OK
|
||||
OK
|
||||
@ -228,6 +234,7 @@ pub enum XmlOtherPutResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum XmlPostResponse {
|
||||
/// OK
|
||||
OK
|
||||
@ -237,6 +244,7 @@ pub enum XmlPostResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum XmlPutResponse {
|
||||
/// OK
|
||||
OK
|
||||
|
@ -138,6 +138,7 @@ pub enum TestClientModelResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum TestEndpointParametersResponse {
|
||||
/// Invalid username supplied
|
||||
InvalidUsernameSupplied
|
||||
@ -147,6 +148,7 @@ pub enum TestEndpointParametersResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum TestEnumParametersResponse {
|
||||
/// Invalid request
|
||||
InvalidRequest
|
||||
@ -187,6 +189,7 @@ pub enum DeletePetResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum FindPetsByStatusResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -197,6 +200,7 @@ pub enum FindPetsByStatusResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum FindPetsByTagsResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -207,6 +211,7 @@ pub enum FindPetsByTagsResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum GetPetByIdResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -220,6 +225,7 @@ pub enum GetPetByIdResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum UpdatePetResponse {
|
||||
/// Invalid ID supplied
|
||||
InvalidIDSupplied
|
||||
@ -245,6 +251,7 @@ pub enum UploadFileResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum DeleteOrderResponse {
|
||||
/// Invalid ID supplied
|
||||
InvalidIDSupplied
|
||||
@ -261,6 +268,7 @@ pub enum GetInventoryResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum GetOrderByIdResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -274,6 +282,7 @@ pub enum GetOrderByIdResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum PlaceOrderResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -302,6 +311,7 @@ pub enum CreateUsersWithListInputResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum DeleteUserResponse {
|
||||
/// Invalid username supplied
|
||||
InvalidUsernameSupplied
|
||||
@ -311,6 +321,7 @@ pub enum DeleteUserResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum GetUserByNameResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -324,6 +335,7 @@ pub enum GetUserByNameResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum LoginUserResponse {
|
||||
/// successful operation
|
||||
SuccessfulOperation
|
||||
@ -344,6 +356,7 @@ pub enum LogoutUserResponse {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[must_use]
|
||||
pub enum UpdateUserResponse {
|
||||
/// Invalid user supplied
|
||||
InvalidUserSupplied
|
||||
|
Loading…
x
Reference in New Issue
Block a user