@@ -28,16 +28,17 @@ use openapiv3::{
2828 MediaType , Parameter , ParameterData , ParameterSchemaOrContent , PathItem , PathStyle , Paths , QueryStyle , ReferenceOr ,
2929 RequestBody , Response , Responses , StatusCode , Example
3030} ;
31+ use serde_json:: Value ;
3132use clients_schema:: SchemaExample ;
32-
3333use crate :: components:: TypesAndComponents ;
34+ use crate :: convert_availabilities;
3435
3536/// Add an endpoint to the OpenAPI schema. This will result in the addition of a number of elements to the
3637/// openapi schema's `paths` and `components` sections.
3738pub fn add_endpoint (
3839 endpoint : & clients_schema:: Endpoint ,
3940 tac : & mut TypesAndComponents ,
40- out : & mut Paths ,
41+ out : & mut Paths
4142) -> anyhow:: Result < ( ) > {
4243 if endpoint. request . is_none ( ) {
4344 // tracing::warn!("Endpoint {} is missing a request -- ignored", &endpoint.name);
@@ -61,6 +62,8 @@ pub fn add_endpoint(
6162 let request = tac. model . get_request ( endpoint. request . as_ref ( ) . unwrap ( ) ) ?;
6263
6364 fn parameter_data ( prop : & Property , in_path : bool , tac : & mut TypesAndComponents ) -> anyhow:: Result < ParameterData > {
65+ let mut extensions: IndexMap < String , Value > = Default :: default ( ) ;
66+ convert_availabilities ( & prop. availability , & tac. config . flavor , & mut extensions) ;
6467 Ok ( ParameterData {
6568 name : prop. name . clone ( ) ,
6669 description : tac. property_description ( prop) ?,
@@ -341,7 +344,7 @@ pub fn add_endpoint(
341344 } ;
342345
343346 // add the x-state extension for availability
344- let mut extensions = crate :: availability_as_extensions ( & endpoint. availability ) ;
347+ let mut extensions = crate :: availability_as_extensions ( & endpoint. availability , & tac . config . flavor ) ;
345348
346349 // add the x-codeSamples extension
347350 let mut code_samples = vec ! [ ] ;
@@ -368,6 +371,8 @@ pub fn add_endpoint(
368371 if !code_samples. is_empty ( ) {
369372 extensions. insert ( "x-codeSamples" . to_string ( ) , serde_json:: json!( code_samples) ) ;
370373 }
374+ let mut ext_availability = crate :: availability_as_extensions ( & endpoint. availability , & tac. config . flavor ) ;
375+ extensions. append ( & mut ext_availability) ;
371376
372377 // Create the operation, it will be repeated if we have several methods
373378 let operation = openapiv3:: Operation {
@@ -392,7 +397,7 @@ pub fn add_endpoint(
392397 deprecated : endpoint. deprecation . is_some ( ) ,
393398 security : None ,
394399 servers : vec ! [ ] ,
395- extensions,
400+ extensions
396401 } ;
397402
398403
0 commit comments