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
1 change: 0 additions & 1 deletion compiler-rs/clients_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,6 @@ pub struct UrlTemplate {
pub struct ModelInfo {
pub title: String,
pub license: License,
pub version: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
7 changes: 7 additions & 0 deletions compiler-rs/clients_schema_to_openapi/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub struct Cli {
#[argh(option)]
pub namespace: Vec<String>,

/// the branch to generate [9.0, 8.19, current, etc... - default = current]
#[argh(option)]
pub branch: Option<String>,

/// add enum descriptions to property descriptions [default = true]
#[argh(switch)]
pub lift_enum_descriptions: bool,
Expand Down Expand Up @@ -72,9 +76,12 @@ impl From<Cli> for Configuration {
SchemaFlavor::Serverless => Some(Flavor::Serverless),
SchemaFlavor::Stack => Some(Flavor::Stack),
};

let branch = cli.branch;

Configuration {
flavor,
branch,
lift_enum_descriptions: cli.lift_enum_descriptions,
merge_multipath_endpoints: cli.merge_multipath_endpoints,
multipath_redirects: cli.multipath_redirects,
Expand Down
1 change: 1 addition & 0 deletions compiler-rs/clients_schema_to_openapi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::components::TypesAndComponents;
pub struct Configuration {
pub flavor: Option<Flavor>,
pub namespaces: Option<Vec<String>>,
pub branch: Option<String>,

/// If a property value is an enumeration, the description of possible values will be copied in the
/// property's description (also works for arrays of enums).
Expand Down
9 changes: 2 additions & 7 deletions compiler-rs/clients_schema_to_openapi/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,14 @@ impl<'a> TypesAndComponents<'a> {
pub fn convert_external_docs(&self, obj: &impl clients_schema::ExternalDocument) -> Option<ExternalDocumentation> {
// FIXME: does the model contain resolved doc_id?
obj.ext_doc_url().map(|url| {
let branch: &str = self
.model
.info
.as_ref()
.and_then(|i| i.version.as_deref())
.unwrap_or("current");
let branch = self.config.branch.clone();
let mut extensions: IndexMap<String,serde_json::Value> = Default::default();
if let Some(previous_version_doc_url) = obj.ext_previous_version_doc_url() {
extensions.insert("x-previousVersionUrl".to_string(), serde_json::json!(previous_version_doc_url));
}
ExternalDocumentation {
description: None,
url: url.trim().replace("{branch}", branch),
url: url.trim().replace("{branch}", &branch.unwrap_or("current".to_string())),
extensions,
}
})
Expand Down