Skip to content
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

Generate schema for v2 manifest #2997

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
40 changes: 40 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ path-absolutize = "3"
regex = { workspace = true }
reqwest = { workspace = true }
rpassword = "7"
schemars = { version = "0.8.21", features = ["indexmap2", "semver"] }
semver = "1"
serde = { version = "1", features = ["derive"] }
serde_json = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/manifest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = { workspace = true }
[dependencies]
anyhow = { workspace = true }
indexmap = { version = "2", features = ["serde"] }
schemars = { version = "0.8.21", features = ["indexmap2", "semver"] }
semver = { version = "1.0", features = ["serde"] }
serde = { workspace = true }
spin-serde = { path = "../serde" }
Expand Down
1 change: 1 addition & 0 deletions crates/manifest/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub fn v1_to_v2_app(manifest: v1::AppManifestV1) -> Result<v2::AppManifest, Erro
};
components.insert(
component_id.clone(),
#[allow(deprecated)]
v2::Component {
source: component.source,
description: component.description,
Expand Down
13 changes: 8 additions & 5 deletions crates/manifest/src/schema/common.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::fmt::Display;

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use wasm_pkg_common::{package::PackageRef, registry::Registry};

/// Variable definition
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Variable {
/// `required = true`
Expand All @@ -20,7 +21,7 @@ pub struct Variable {
}

/// Component source
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields, untagged)]
pub enum ComponentSource {
/// `"local.wasm"`
Expand All @@ -35,8 +36,10 @@ pub enum ComponentSource {
/// `{ ... }`
Registry {
/// `registry = "example.com"`
#[schemars(with = "Option<String>")]
registry: Option<Registry>,
/// `package = "example:component"`
#[schemars(with = "String")]
package: PackageRef,
/// `version = "1.2.3"`
version: String,
Expand Down Expand Up @@ -64,7 +67,7 @@ impl Display for ComponentSource {
}

/// WASI files mount
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields, untagged)]
pub enum WasiFilesMount {
/// `"images/*.png"`
Expand All @@ -79,7 +82,7 @@ pub enum WasiFilesMount {
}

/// Component build configuration
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ComponentBuildConfig {
/// `command = "cargo build"`
Expand All @@ -104,7 +107,7 @@ impl ComponentBuildConfig {
}

/// Component build command or commands
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
pub enum Commands {
/// `command = "cargo build"`
Expand Down
Loading
Loading