@@ -13,8 +13,6 @@ use crate::views::EncodableOwner;
1313use crate :: { App , app:: AppState } ;
1414use crate :: { auth:: AuthCheck , email:: Email } ;
1515use axum:: Json ;
16- use axum_extra:: json;
17- use axum_extra:: response:: ErasedJson ;
1816use chrono:: Utc ;
1917use crates_io_github:: { GitHubClient , GitHubError } ;
2018use diesel:: prelude:: * ;
@@ -102,6 +100,16 @@ pub async fn get_user_owners(state: AppState, path: CratePath) -> AppResult<Json
102100 Ok ( Json ( UsersResponse { users } ) )
103101}
104102
103+ #[ derive( Debug , Serialize , utoipa:: ToSchema ) ]
104+ pub struct ModifyResponse {
105+ /// A message describing the result of the operation.
106+ #[ schema( example = "user ghost has been invited to be an owner of crate serde" ) ]
107+ pub msg : String ,
108+
109+ #[ schema( example = true ) ]
110+ pub ok : bool ,
111+ }
112+
105113/// Add crate owners.
106114#[ utoipa:: path(
107115 put,
@@ -112,14 +120,14 @@ pub async fn get_user_owners(state: AppState, path: CratePath) -> AppResult<Json
112120 ( "cookie" = [ ] ) ,
113121 ) ,
114122 tag = "owners" ,
115- responses( ( status = 200 , description = "Successful Response" ) ) ,
123+ responses( ( status = 200 , description = "Successful Response" , body = inline ( ModifyResponse ) ) ) ,
116124) ]
117125pub async fn add_owners (
118126 app : AppState ,
119127 path : CratePath ,
120128 parts : Parts ,
121129 Json ( body) : Json < ChangeOwnersRequest > ,
122- ) -> AppResult < ErasedJson > {
130+ ) -> AppResult < Json < ModifyResponse > > {
123131 modify_owners ( app, path. name , parts, body, true ) . await
124132}
125133
@@ -133,14 +141,14 @@ pub async fn add_owners(
133141 ( "cookie" = [ ] ) ,
134142 ) ,
135143 tag = "owners" ,
136- responses( ( status = 200 , description = "Successful Response" ) ) ,
144+ responses( ( status = 200 , description = "Successful Response" , body = inline ( ModifyResponse ) ) ) ,
137145) ]
138146pub async fn remove_owners (
139147 app : AppState ,
140148 path : CratePath ,
141149 parts : Parts ,
142150 Json ( body) : Json < ChangeOwnersRequest > ,
143- ) -> AppResult < ErasedJson > {
151+ ) -> AppResult < Json < ModifyResponse > > {
144152 modify_owners ( app, path. name , parts, body, false ) . await
145153}
146154
@@ -156,7 +164,7 @@ async fn modify_owners(
156164 parts : Parts ,
157165 body : ChangeOwnersRequest ,
158166 add : bool ,
159- ) -> AppResult < ErasedJson > {
167+ ) -> AppResult < Json < ModifyResponse > > {
160168 let logins = body. owners ;
161169
162170 // Bound the number of invites processed per request to limit the cost of
@@ -176,7 +184,7 @@ async fn modify_owners(
176184
177185 let user = auth. user ( ) ;
178186
179- let ( comma_sep_msg , emails) = conn
187+ let ( msg , emails) = conn
180188 . transaction ( |conn| {
181189 let app = app. clone ( ) ;
182190 async move {
@@ -291,7 +299,7 @@ async fn modify_owners(
291299 }
292300 }
293301
294- Ok ( json ! ( { " msg" : comma_sep_msg , "ok" : true } ) )
302+ Ok ( Json ( ModifyResponse { msg, ok : true } ) )
295303}
296304
297305/// Invite `login` as an owner of this crate, returning the created
0 commit comments