Skip to content

Commit

Permalink
Make extensions that don't use project templates backwards-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop committed Jan 10, 2025
1 parent 4a6e21a commit fdcd1c7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/dfx-core/src/extension/manifest/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ const DEFAULT_DOWNLOAD_URL_TEMPLATE: &str =
type SubcmdName = String;
type ArgName = String;

fn should_skip_serializing_project_templates(
project_templates: &Option<HashMap<String, ExtensionProjectTemplate>>,
) -> bool {
project_templates
.as_ref()
.map(HashMap::is_empty)
.unwrap_or(true)
}

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ExtensionManifest {
Expand All @@ -37,6 +46,10 @@ pub struct ExtensionManifest {
pub dependencies: Option<HashMap<String, ExtensionDependency>>,
pub canister_type: Option<ExtensionCanisterType>,

#[serde(
default,
skip_serializing_if = "should_skip_serializing_project_templates"
)]
pub project_templates: Option<HashMap<String, ExtensionProjectTemplate>>,

/// Components of the download url template are:
Expand Down

0 comments on commit fdcd1c7

Please sign in to comment.