@@ -242,12 +242,28 @@ impl<'a> TypesAndComponents<'a> {
242242 }
243243
244244 fn convert_property ( & mut self , prop : & Property ) -> anyhow:: Result < ReferenceOr < Schema > > {
245- let mut result = self . convert_value_of ( & prop. typ ) ?;
246- // TODO: how can we just wrap a reference so that we can add docs?
247- if let ReferenceOr :: Item ( ref mut schema) = & mut result {
248- self . fill_data_with_prop ( & mut schema. schema_data , prop) ?;
249- }
250- Ok ( result)
245+ let result = self . convert_value_of ( & prop. typ ) ?;
246+
247+ // OpenAPI 3.0 doesn't allow adding summary and description to a reference. The recommended workaround
248+ // is to use a schema with a single `allOf` - see https://github.com/OAI/OpenAPI-Specification/issues/1514
249+ //
250+ // OpenAPI 3.1 added summary and description for a `$ref` have been added to avoid the workaround
251+ // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object
252+
253+ let mut schema = match result {
254+ ReferenceOr :: Item ( schema) => schema,
255+ reference @ ReferenceOr :: Reference { reference : _ } => Schema {
256+ schema_kind : SchemaKind :: AllOf {
257+ all_of : vec ! [ reference]
258+ } ,
259+ schema_data : Default :: default ( ) ,
260+ }
261+ } ;
262+
263+ // Add docs & other properties
264+ self . fill_data_with_prop ( & mut schema. schema_data , prop) ?;
265+
266+ Ok ( ReferenceOr :: Item ( schema) )
251267 }
252268
253269 fn convert_properties < ' b > (
0 commit comments