@@ -23,6 +23,7 @@ use clients_schema::{Privileges, Property};
23
23
use indexmap:: IndexMap ;
24
24
use indexmap:: indexmap;
25
25
use icu_segmenter:: SentenceSegmenter ;
26
+ use itertools:: Itertools ;
26
27
use openapiv3:: {
27
28
MediaType , Parameter , ParameterData , ParameterSchemaOrContent , PathItem , PathStyle , Paths , QueryStyle , ReferenceOr ,
28
29
RequestBody , Response , Responses , StatusCode , Example
@@ -293,6 +294,8 @@ pub fn add_endpoint(
293
294
if !code_samples. is_empty ( ) {
294
295
extensions. insert ( "x-codeSamples" . to_string ( ) , serde_json:: json!( code_samples) ) ;
295
296
}
297
+ let mut ext_availability = crate :: availability_as_extensions ( & endpoint. availability ) ;
298
+ extensions. append ( & mut ext_availability) ;
296
299
297
300
// Create the operation, it will be repeated if we have several methods
298
301
let operation = openapiv3:: Operation {
@@ -317,7 +320,7 @@ pub fn add_endpoint(
317
320
deprecated : endpoint. deprecation . is_some ( ) ,
318
321
security : None ,
319
322
servers : vec ! [ ] ,
320
- extensions : crate :: availability_as_extensions ( & endpoint . availability ) ,
323
+ extensions
321
324
} ;
322
325
323
326
@@ -449,15 +452,17 @@ fn split_summary_desc(desc: &str) -> SplitDesc{
449
452
fn add_privileges ( privileges : & Option < Privileges > ) -> Option < String > {
450
453
if let Some ( privs) = privileges {
451
454
let mut result = "\n ##Required authorization\n " . to_string ( ) ;
452
- if privs. index . len ( ) >0 {
453
- result = result + "* Index privileges: " + & privs. index . iter ( )
454
- . map ( |a| { "`" . to_string ( ) + a + "`" } )
455
- . collect :: < Vec < String > > ( ) . join ( "," ) ;
455
+ if !privs. index . is_empty ( ) {
456
+ result += "* Index privileges: " ;
457
+ result += & privs. index . iter ( )
458
+ . map ( |a| format ! ( "`{a}`" ) )
459
+ . join ( "," ) ;
456
460
}
457
- if privs. cluster . len ( ) >0 {
458
- result = result + " * Cluster privileges: " + & privs. cluster . iter ( )
459
- . map ( |a| { "`" . to_string ( ) + a + "`" } )
460
- . collect :: < Vec < String > > ( ) . join ( "," ) ;
461
+ if !privs. cluster . is_empty ( ) {
462
+ result += "* Cluster privileges: " ;
463
+ result += & privs. cluster . iter ( )
464
+ . map ( |a| format ! ( "`{a}`" ) )
465
+ . join ( "," ) ;
461
466
}
462
467
return Some ( result)
463
468
}
0 commit comments