77use axum:: Json ;
88use axum_extra:: json;
99use axum_extra:: response:: ErasedJson ;
10- use crates_io_database:: schema:: { crates, dependencies} ;
1110use crates_io_worker:: BackgroundJob ;
1211use diesel:: prelude:: * ;
1312use diesel_async:: { AsyncPgConnection , RunQueryDsl } ;
@@ -19,12 +18,12 @@ use crate::app::AppState;
1918use crate :: auth:: { AuthCheck , Authentication } ;
2019use crate :: models:: token:: EndpointScope ;
2120use crate :: models:: {
22- Crate , Dependency , NewVersionOwnerAction , Rights , Version , VersionAction , VersionOwnerAction ,
21+ Crate , NewVersionOwnerAction , Rights , Version , VersionAction , VersionOwnerAction ,
2322} ;
2423use crate :: rate_limiter:: LimitedAction ;
2524use crate :: schema:: versions;
2625use crate :: util:: errors:: { bad_request, custom, AppResult } ;
27- use crate :: views:: { EncodableDependency , EncodableVersion } ;
26+ use crate :: views:: EncodableVersion ;
2827use crate :: worker:: jobs:: { SyncToGitIndex , SyncToSparseIndex , UpdateDefaultVersion } ;
2928
3029use super :: CrateVersionPath ;
@@ -39,40 +38,6 @@ pub struct VersionUpdateRequest {
3938 version : VersionUpdate ,
4039}
4140
42- /// Get crate version dependencies.
43- ///
44- /// This information can also be obtained directly from the index.
45- ///
46- /// In addition to returning cached data from the index, this returns
47- /// fields for `id`, `version_id`, and `downloads` (which appears to always
48- /// be 0)
49- #[ utoipa:: path(
50- get,
51- path = "/api/v1/crates/{name}/{version}/dependencies" ,
52- params( CrateVersionPath ) ,
53- tag = "versions" ,
54- responses( ( status = 200 , description = "Successful Response" ) ) ,
55- ) ]
56- pub async fn get_version_dependencies (
57- state : AppState ,
58- path : CrateVersionPath ,
59- ) -> AppResult < ErasedJson > {
60- let mut conn = state. db_read ( ) . await ?;
61- let version = path. load_version ( & mut conn) . await ?;
62-
63- let deps = Dependency :: belonging_to ( & version)
64- . inner_join ( crates:: table)
65- . select ( ( Dependency :: as_select ( ) , crates:: name) )
66- . order ( ( dependencies:: optional, crates:: name) )
67- . load :: < ( Dependency , String ) > ( & mut conn)
68- . await ?
69- . into_iter ( )
70- . map ( |( dep, crate_name) | EncodableDependency :: from_dep ( dep, & crate_name) )
71- . collect :: < Vec < _ > > ( ) ;
72-
73- Ok ( json ! ( { "dependencies" : deps } ) )
74- }
75-
7641/// Get crate version authors.
7742///
7843/// This endpoint was deprecated by [RFC #3052](https://github.com/rust-lang/rfcs/pull/3052)
0 commit comments