Skip to content
Closed
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
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:

- name: Setup Extism
run: |
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh
bash install.sh
curl https://raw.githubusercontent.com/extism/js-pdk/main/install.sh | bash

- name: Set up Node.js
uses: actions/setup-node@v2
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"typescript": "^5.3.2"
},
"dependencies": {
"@dylibso/xtp-bindgen": "1.0.0-rc.8",
"@dylibso/xtp-bindgen": "1.0.0-rc.11",
"ejs": "^3.1.10"
}
}
14 changes: 11 additions & 3 deletions template/src/pdk.rs.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ pub extern "C" fn <%- ex.name %>() -> i32 {
}

pub mod types {
#[derive(serde::Serialize, serde::Deserialize, extism_pdk::FromBytes, extism_pdk::ToBytes)]
#[encoding(Json)]
#[serde(transparent)]
pub struct Base64(#[serde(with = "Base64Standard")] pub Vec<u8>);

use super::*;
<% Object.values(schema.schemas).forEach(schema => { %>
<% if (schema.enum) { %>
Expand All @@ -85,9 +90,12 @@ pub struct <%- capitalize(schema.name) %> {
/// <%- formatCommentBlock(p.description, "/// ") %>
<% } -%>
#[serde(rename = "<%- p.name %>")]
<% if (p.nullable) { %>#[serde(default)]<% } %>
<% if (p.type === "buffer") { %> #[serde(with = "Base64Standard")] <% } %>
<%- makePublic(camelToSnakeCase(p.name)) %>: <%- p.nullable ? `Option<${toRustType(p)}>` : toRustType(p) %>,
<% if (!p.required && p.nullable) { %> #[serde(skip_serializing_if = "Option::is_none")] <% } %>
<% if (p.type === "buffer") { %>
<%- makePublic(camelToSnakeCase(p.name)) %>: <%- p.nullable || !p.required ? `Option<Base64>` : Base64 %>,
<% } else { %>
<%- makePublic(camelToSnakeCase(p.name)) %>: <%- p.nullable || !p.required ? `Option<${toRustType(p)}>` : toRustType(p) %>,
<% } %>
<% }) %>

<% if (schema.additionalProperties) { %>
Expand Down
4 changes: 4 additions & 0 deletions tests/schemas/fruit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ components:
writeParams:
"$ref": "#/components/schemas/WriteParams"
nullable: true
required:
- aString
- aDate
- writeParams
description: A complex json object
Loading