Skip to content

Commit cfef948

Browse files
authored
[Rust-Axum] [Breaking Changes] Prevent Operation response with internal Error (#20047)
* [Rust-Axum] Fix: prevent Operation returns Internal Server Error * Update
1 parent 8675874 commit cfef948

File tree

20 files changed

+141
-144
lines changed

20 files changed

+141
-144
lines changed

modules/openapi-generator/src/main/resources/rust-axum/apis.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub trait {{classnamePascalCase}} {
7272
{{#x-consumes-multipart-related}}
7373
body: axum::body::Body,
7474
{{/x-consumes-multipart-related}}
75-
) -> Result<{{{operationId}}}Response, String>;
75+
) -> Result<{{{operationId}}}Response, ()>;
7676
{{/vendorExtensions}}
7777
{{^-last}}
7878

samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait Payments {
4848
host: Host,
4949
cookies: CookieJar,
5050
path_params: models::GetPaymentMethodByIdPathParams,
51-
) -> Result<GetPaymentMethodByIdResponse, String>;
51+
) -> Result<GetPaymentMethodByIdResponse, ()>;
5252

5353
/// Get payment methods.
5454
///
@@ -58,7 +58,7 @@ pub trait Payments {
5858
method: Method,
5959
host: Host,
6060
cookies: CookieJar,
61-
) -> Result<GetPaymentMethodsResponse, String>;
61+
) -> Result<GetPaymentMethodsResponse, ()>;
6262

6363
/// Make a payment.
6464
///
@@ -70,5 +70,5 @@ pub trait Payments {
7070
cookies: CookieJar,
7171
token_in_cookie: Option<String>,
7272
body: Option<models::Payment>,
73-
) -> Result<PostMakePaymentResponse, String>;
73+
) -> Result<PostMakePaymentResponse, ()>;
7474
}

samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub trait Default {
4242
host: Host,
4343
cookies: CookieJar,
4444
body: axum::body::Body,
45-
) -> Result<MultipartRelatedRequestPostResponse, String>;
45+
) -> Result<MultipartRelatedRequestPostResponse, ()>;
4646

4747
/// MultipartRequestPost - POST /multipart_request
4848
async fn multipart_request_post(
@@ -51,7 +51,7 @@ pub trait Default {
5151
host: Host,
5252
cookies: CookieJar,
5353
body: Multipart,
54-
) -> Result<MultipartRequestPostResponse, String>;
54+
) -> Result<MultipartRequestPostResponse, ()>;
5555

5656
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
5757
async fn multiple_identical_mime_types_post(
@@ -60,5 +60,5 @@ pub trait Default {
6060
host: Host,
6161
cookies: CookieJar,
6262
body: axum::body::Body,
63-
) -> Result<MultipleIdenticalMimeTypesPostResponse, String>;
63+
) -> Result<MultipleIdenticalMimeTypesPostResponse, ()>;
6464
}

samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub trait Default {
282282
host: Host,
283283
cookies: CookieJar,
284284
query_params: models::AnyOfGetQueryParams,
285-
) -> Result<AnyOfGetResponse, String>;
285+
) -> Result<AnyOfGetResponse, ()>;
286286

287287
/// CallbackWithHeaderPost - POST /callback-with-header
288288
async fn callback_with_header_post(
@@ -291,7 +291,7 @@ pub trait Default {
291291
host: Host,
292292
cookies: CookieJar,
293293
query_params: models::CallbackWithHeaderPostQueryParams,
294-
) -> Result<CallbackWithHeaderPostResponse, String>;
294+
) -> Result<CallbackWithHeaderPostResponse, ()>;
295295

296296
/// ComplexQueryParamGet - GET /complex-query-param
297297
async fn complex_query_param_get(
@@ -300,7 +300,7 @@ pub trait Default {
300300
host: Host,
301301
cookies: CookieJar,
302302
query_params: models::ComplexQueryParamGetQueryParams,
303-
) -> Result<ComplexQueryParamGetResponse, String>;
303+
) -> Result<ComplexQueryParamGetResponse, ()>;
304304

305305
/// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
306306
async fn enum_in_path_path_param_get(
@@ -309,7 +309,7 @@ pub trait Default {
309309
host: Host,
310310
cookies: CookieJar,
311311
path_params: models::EnumInPathPathParamGetPathParams,
312-
) -> Result<EnumInPathPathParamGetResponse, String>;
312+
) -> Result<EnumInPathPathParamGetResponse, ()>;
313313

314314
/// Test a Form Post.
315315
///
@@ -320,7 +320,7 @@ pub trait Default {
320320
host: Host,
321321
cookies: CookieJar,
322322
body: models::FormTestRequest,
323-
) -> Result<FormTestResponse, String>;
323+
) -> Result<FormTestResponse, ()>;
324324

325325
/// GetWithBooleanParameter - GET /get-with-bool
326326
async fn get_with_boolean_parameter(
@@ -329,7 +329,7 @@ pub trait Default {
329329
host: Host,
330330
cookies: CookieJar,
331331
query_params: models::GetWithBooleanParameterQueryParams,
332-
) -> Result<GetWithBooleanParameterResponse, String>;
332+
) -> Result<GetWithBooleanParameterResponse, ()>;
333333

334334
/// JsonComplexQueryParamGet - GET /json-complex-query-param
335335
async fn json_complex_query_param_get(
@@ -338,7 +338,7 @@ pub trait Default {
338338
host: Host,
339339
cookies: CookieJar,
340340
query_params: models::JsonComplexQueryParamGetQueryParams,
341-
) -> Result<JsonComplexQueryParamGetResponse, String>;
341+
) -> Result<JsonComplexQueryParamGetResponse, ()>;
342342

343343
/// MandatoryRequestHeaderGet - GET /mandatory-request-header
344344
async fn mandatory_request_header_get(
@@ -347,15 +347,15 @@ pub trait Default {
347347
host: Host,
348348
cookies: CookieJar,
349349
header_params: models::MandatoryRequestHeaderGetHeaderParams,
350-
) -> Result<MandatoryRequestHeaderGetResponse, String>;
350+
) -> Result<MandatoryRequestHeaderGetResponse, ()>;
351351

352352
/// MergePatchJsonGet - GET /merge-patch-json
353353
async fn merge_patch_json_get(
354354
&self,
355355
method: Method,
356356
host: Host,
357357
cookies: CookieJar,
358-
) -> Result<MergePatchJsonGetResponse, String>;
358+
) -> Result<MergePatchJsonGetResponse, ()>;
359359

360360
/// Get some stuff..
361361
///
@@ -365,15 +365,15 @@ pub trait Default {
365365
method: Method,
366366
host: Host,
367367
cookies: CookieJar,
368-
) -> Result<MultigetGetResponse, String>;
368+
) -> Result<MultigetGetResponse, ()>;
369369

370370
/// MultipleAuthSchemeGet - GET /multiple_auth_scheme
371371
async fn multiple_auth_scheme_get(
372372
&self,
373373
method: Method,
374374
host: Host,
375375
cookies: CookieJar,
376-
) -> Result<MultipleAuthSchemeGetResponse, String>;
376+
) -> Result<MultipleAuthSchemeGetResponse, ()>;
377377

378378
/// MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet - GET /multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b}
379379
async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get(
@@ -382,26 +382,23 @@ pub trait Default {
382382
host: Host,
383383
cookies: CookieJar,
384384
path_params: models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams,
385-
) -> Result<
386-
MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetResponse,
387-
String,
388-
>;
385+
) -> Result<MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetResponse, ()>;
389386

390387
/// OneOfGet - GET /one-of
391388
async fn one_of_get(
392389
&self,
393390
method: Method,
394391
host: Host,
395392
cookies: CookieJar,
396-
) -> Result<OneOfGetResponse, String>;
393+
) -> Result<OneOfGetResponse, ()>;
397394

398395
/// OverrideServerGet - GET /override-server
399396
async fn override_server_get(
400397
&self,
401398
method: Method,
402399
host: Host,
403400
cookies: CookieJar,
404-
) -> Result<OverrideServerGetResponse, String>;
401+
) -> Result<OverrideServerGetResponse, ()>;
405402

406403
/// Get some stuff with parameters..
407404
///
@@ -412,15 +409,15 @@ pub trait Default {
412409
host: Host,
413410
cookies: CookieJar,
414411
query_params: models::ParamgetGetQueryParams,
415-
) -> Result<ParamgetGetResponse, String>;
412+
) -> Result<ParamgetGetResponse, ()>;
416413

417414
/// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
418415
async fn readonly_auth_scheme_get(
419416
&self,
420417
method: Method,
421418
host: Host,
422419
cookies: CookieJar,
423-
) -> Result<ReadonlyAuthSchemeGetResponse, String>;
420+
) -> Result<ReadonlyAuthSchemeGetResponse, ()>;
424421

425422
/// RegisterCallbackPost - POST /register-callback
426423
async fn register_callback_post(
@@ -429,7 +426,7 @@ pub trait Default {
429426
host: Host,
430427
cookies: CookieJar,
431428
query_params: models::RegisterCallbackPostQueryParams,
432-
) -> Result<RegisterCallbackPostResponse, String>;
429+
) -> Result<RegisterCallbackPostResponse, ()>;
433430

434431
/// RequiredOctetStreamPut - PUT /required_octet_stream
435432
async fn required_octet_stream_put(
@@ -438,23 +435,23 @@ pub trait Default {
438435
host: Host,
439436
cookies: CookieJar,
440437
body: Bytes,
441-
) -> Result<RequiredOctetStreamPutResponse, String>;
438+
) -> Result<RequiredOctetStreamPutResponse, ()>;
442439

443440
/// ResponsesWithHeadersGet - GET /responses_with_headers
444441
async fn responses_with_headers_get(
445442
&self,
446443
method: Method,
447444
host: Host,
448445
cookies: CookieJar,
449-
) -> Result<ResponsesWithHeadersGetResponse, String>;
446+
) -> Result<ResponsesWithHeadersGetResponse, ()>;
450447

451448
/// Rfc7807Get - GET /rfc7807
452449
async fn rfc7807_get(
453450
&self,
454451
method: Method,
455452
host: Host,
456453
cookies: CookieJar,
457-
) -> Result<Rfc7807GetResponse, String>;
454+
) -> Result<Rfc7807GetResponse, ()>;
458455

459456
/// TwoFirstLetterHeaders - POST /operation-two-first-letter-headers
460457
async fn two_first_letter_headers(
@@ -463,7 +460,7 @@ pub trait Default {
463460
host: Host,
464461
cookies: CookieJar,
465462
header_params: models::TwoFirstLetterHeadersHeaderParams,
466-
) -> Result<TwoFirstLetterHeadersResponse, String>;
463+
) -> Result<TwoFirstLetterHeadersResponse, ()>;
467464

468465
/// UntypedPropertyGet - GET /untyped_property
469466
async fn untyped_property_get(
@@ -472,15 +469,15 @@ pub trait Default {
472469
host: Host,
473470
cookies: CookieJar,
474471
body: Option<models::ObjectUntypedProps>,
475-
) -> Result<UntypedPropertyGetResponse, String>;
472+
) -> Result<UntypedPropertyGetResponse, ()>;
476473

477474
/// UuidGet - GET /uuid
478475
async fn uuid_get(
479476
&self,
480477
method: Method,
481478
host: Host,
482479
cookies: CookieJar,
483-
) -> Result<UuidGetResponse, String>;
480+
) -> Result<UuidGetResponse, ()>;
484481

485482
/// XmlExtraPost - POST /xml_extra
486483
async fn xml_extra_post(
@@ -489,7 +486,7 @@ pub trait Default {
489486
host: Host,
490487
cookies: CookieJar,
491488
body: Bytes,
492-
) -> Result<XmlExtraPostResponse, String>;
489+
) -> Result<XmlExtraPostResponse, ()>;
493490

494491
/// XmlOtherPost - POST /xml_other
495492
async fn xml_other_post(
@@ -498,7 +495,7 @@ pub trait Default {
498495
host: Host,
499496
cookies: CookieJar,
500497
body: Bytes,
501-
) -> Result<XmlOtherPostResponse, String>;
498+
) -> Result<XmlOtherPostResponse, ()>;
502499

503500
/// XmlOtherPut - PUT /xml_other
504501
async fn xml_other_put(
@@ -507,7 +504,7 @@ pub trait Default {
507504
host: Host,
508505
cookies: CookieJar,
509506
body: Bytes,
510-
) -> Result<XmlOtherPutResponse, String>;
507+
) -> Result<XmlOtherPutResponse, ()>;
511508

512509
/// Post an array. It's important we test apostrophes, so include one here..
513510
///
@@ -518,7 +515,7 @@ pub trait Default {
518515
host: Host,
519516
cookies: CookieJar,
520517
body: Bytes,
521-
) -> Result<XmlPostResponse, String>;
518+
) -> Result<XmlPostResponse, ()>;
522519

523520
/// XmlPut - PUT /xml
524521
async fn xml_put(
@@ -527,5 +524,5 @@ pub trait Default {
527524
host: Host,
528525
cookies: CookieJar,
529526
body: Bytes,
530-
) -> Result<XmlPutResponse, String>;
527+
) -> Result<XmlPutResponse, ()>;
531528
}

samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ pub trait InfoRepo {
2626
host: Host,
2727
cookies: CookieJar,
2828
path_params: models::GetRepoInfoPathParams,
29-
) -> Result<GetRepoInfoResponse, String>;
29+
) -> Result<GetRepoInfoResponse, ()>;
3030
}

samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ pub trait Repo {
2626
host: Host,
2727
cookies: CookieJar,
2828
body: models::ObjectParam,
29-
) -> Result<CreateRepoResponse, String>;
29+
) -> Result<CreateRepoResponse, ()>;
3030
}

0 commit comments

Comments
 (0)