From b8991aed0f4c9f58daad1865a3873fc31bdc96bd Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 2 Feb 2021 11:42:43 -0800 Subject: re-codegen openapi stuff --- rust/fatcat-openapi/examples/client/main.rs | 103 +++++++++++++++------------- 1 file changed, 56 insertions(+), 47 deletions(-) (limited to 'rust/fatcat-openapi/examples/client') diff --git a/rust/fatcat-openapi/examples/client/main.rs b/rust/fatcat-openapi/examples/client/main.rs index 0bc6662..14a1bdf 100644 --- a/rust/fatcat-openapi/examples/client/main.rs +++ b/rust/fatcat-openapi/examples/client/main.rs @@ -3,39 +3,39 @@ use clap::{App, Arg}; #[allow(unused_imports)] use fatcat_openapi::{ - models, AcceptEditgroupResponse, Api, ApiError, ApiNoContext, AuthCheckResponse, - AuthOidcResponse, Client, ContextWrapperExt, CreateAuthTokenResponse, - CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, - CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, - CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, - CreateFilesetResponse, CreateReleaseAutoBatchResponse, CreateReleaseResponse, - CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, - CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, - DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, - DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, - DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, - DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, - GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, - GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, - GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, - GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, - GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, - GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, - GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, - GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, - GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, - GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, - GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, - GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, - GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, - UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, - UpdateWebcaptureResponse, UpdateWorkResponse, + models, AcceptEditgroupResponse, Api, ApiNoContext, AuthCheckResponse, AuthOidcResponse, + Client, ContextWrapperExt, CreateAuthTokenResponse, CreateContainerAutoBatchResponse, + CreateContainerResponse, CreateCreatorAutoBatchResponse, CreateCreatorResponse, + CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, + CreateFileResponse, CreateFilesetAutoBatchResponse, CreateFilesetResponse, + CreateReleaseAutoBatchResponse, CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, + CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, + DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, + DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, + DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, + DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, + DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, + GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, + GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, + GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, + GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, + GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, + GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, + GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, + GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, + GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, + GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, + GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, + GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, + GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, + GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, + LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, + UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, + UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, + UpdateWorkResponse, }; #[allow(unused_imports)] -use futures::{future, stream, Future, Stream}; +use futures::{future, stream, Stream}; #[allow(unused_imports)] use log::info; @@ -44,6 +44,13 @@ use log::info; #[allow(unused_imports)] use swagger::{AuthData, ContextBuilder, EmptyContext, Has, Push, XSpanIdString}; +type ClientContext = swagger::make_context_ty!( + ContextBuilder, + EmptyContext, + Option, + XSpanIdString +); + // rt may be unused if there are no examples #[allow(unused_mut)] fn main() { @@ -156,27 +163,24 @@ fn main() { matches.value_of("port").unwrap() ); - let client = if matches.is_present("https") { - // Using Simple HTTPS - Client::try_new_https(&base_url).expect("Failed to create HTTPS client") - } else { - // Using HTTP - Client::try_new_http(&base_url).expect("Failed to create HTTP client") - }; - - let context: swagger::make_context_ty!( - ContextBuilder, - EmptyContext, - Option, - XSpanIdString - ) = swagger::make_context!( + let context: ClientContext = swagger::make_context!( ContextBuilder, EmptyContext, None as Option, XSpanIdString::default() ); - let client = client.with_context(context); + let mut client: Box> = if matches.is_present("https") { + // Using Simple HTTPS + let client = + Box::new(Client::try_new_https(&base_url).expect("Failed to create HTTPS client")); + Box::new(client.with_context(context)) + } else { + // Using HTTP + let client = + Box::new(Client::try_new_http(&base_url).expect("Failed to create HTTP client")); + Box::new(client.with_context(context)) + }; let mut rt = tokio::runtime::Runtime::new().unwrap(); @@ -1036,6 +1040,9 @@ fn main() { Some("jstor_example".to_string()), Some("ark_example".to_string()), Some("mag_example".to_string()), + Some("doaj_example".to_string()), + Some("dblp_example".to_string()), + Some("oai_example".to_string()), Some("expand_example".to_string()), Some("hide_example".to_string()), )); @@ -1134,6 +1141,8 @@ fn main() { info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, */ - _ => panic!("Invalid operation provided"), + _ => { + panic!("Invalid operation provided") + } } } -- cgit v1.2.3