Skip to content

Generate a docs for properties that are a simple reference #5129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
84 changes: 35 additions & 49 deletions compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading