@@ -19,24 +19,25 @@ use std::collections::HashMap;
1919use std:: fmt:: Write ;
2020
2121use anyhow:: { anyhow, bail} ;
22- use clients_schema:: Property ;
22+ use clients_schema:: { Property } ;
2323use indexmap:: IndexMap ;
2424use indexmap:: indexmap;
2525use icu_segmenter:: SentenceSegmenter ;
2626use openapiv3:: {
2727 MediaType , Parameter , ParameterData , ParameterSchemaOrContent , PathItem , PathStyle , Paths , QueryStyle , ReferenceOr ,
2828 RequestBody , Response , Responses , StatusCode , Example
2929} ;
30+ use serde_json:: Value ;
3031use clients_schema:: SchemaExample ;
31-
3232use crate :: components:: TypesAndComponents ;
33+ use crate :: convert_availabilities;
3334
3435/// Add an endpoint to the OpenAPI schema. This will result in the addition of a number of elements to the
3536/// openapi schema's `paths` and `components` sections.
3637pub fn add_endpoint (
3738 endpoint : & clients_schema:: Endpoint ,
3839 tac : & mut TypesAndComponents ,
39- out : & mut Paths ,
40+ out : & mut Paths
4041) -> anyhow:: Result < ( ) > {
4142 if endpoint. request . is_none ( ) {
4243 // tracing::warn!("Endpoint {} is missing a request -- ignored", &endpoint.name);
@@ -60,6 +61,8 @@ pub fn add_endpoint(
6061 let request = tac. model . get_request ( endpoint. request . as_ref ( ) . unwrap ( ) ) ?;
6162
6263 fn parameter_data ( prop : & Property , in_path : bool , tac : & mut TypesAndComponents ) -> anyhow:: Result < ParameterData > {
64+ let mut extensions: IndexMap < String , Value > = Default :: default ( ) ;
65+ convert_availabilities ( & prop. availability , & tac. config . flavor , & mut extensions) ;
6366 Ok ( ParameterData {
6467 name : prop. name . clone ( ) ,
6568 description : tac. property_description ( prop) ?,
@@ -252,7 +255,7 @@ pub fn add_endpoint(
252255 let sum_desc = split_summary_desc ( & endpoint. description ) ;
253256
254257 // add the x-state extension for availability
255- let mut extensions = crate :: availability_as_extensions ( & endpoint. availability ) ;
258+ let mut extensions = crate :: availability_as_extensions ( & endpoint. availability , & tac . config . flavor ) ;
256259
257260 // add the x-codeSamples extension
258261 let mut code_samples = vec ! [ ] ;
@@ -286,6 +289,8 @@ pub fn add_endpoint(
286289 if !code_samples. is_empty ( ) {
287290 extensions. insert ( "x-codeSamples" . to_string ( ) , serde_json:: json!( code_samples) ) ;
288291 }
292+ let mut ext_availability = crate :: availability_as_extensions ( & endpoint. availability , & tac. config . flavor ) ;
293+ extensions. append ( & mut ext_availability) ;
289294
290295 // Create the operation, it will be repeated if we have several methods
291296 let operation = openapiv3:: Operation {
@@ -310,7 +315,7 @@ pub fn add_endpoint(
310315 deprecated : endpoint. deprecation . is_some ( ) ,
311316 security : None ,
312317 servers : vec ! [ ] ,
313- extensions,
318+ extensions
314319 } ;
315320
316321
0 commit comments