Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions compiler-rs/clients_schema_to_openapi/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,28 @@ impl<'a> TypesAndComponents<'a> {
}

fn convert_property(&mut self, prop: &Property) -> anyhow::Result<ReferenceOr<Schema>> {
let mut result = self.convert_value_of(&prop.typ)?;
// TODO: how can we just wrap a reference so that we can add docs?
if let ReferenceOr::Item(ref mut schema) = &mut result {
self.fill_data_with_prop(&mut schema.schema_data, prop)?;
}
Ok(result)
let result = self.convert_value_of(&prop.typ)?;

// OpenAPI 3.0 doesn't allow adding summary and description to a reference. The recommended workaround
// is to use a schema with a single `allOf` - see https://github.com/OAI/OpenAPI-Specification/issues/1514
//
// OpenAPI 3.1 added summary and description for a `$ref` have been added to avoid the workaround
// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object

let mut schema = match result {
ReferenceOr::Item(schema) => schema,
reference @ ReferenceOr::Reference { reference: _ } => Schema {
schema_kind: SchemaKind::AllOf {
all_of: vec![reference]
},
schema_data: Default::default(),
}
};

// Add docs & other properties
self.fill_data_with_prop(&mut schema.schema_data, prop)?;

Ok(ReferenceOr::Item(schema))
}

fn convert_properties<'b>(
Expand Down
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
Loading