Skip to content

Commit

Permalink
Document extism.Json
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelx committed Oct 23, 2024
1 parent b70c5df commit b2dcee7
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Extism Python PDK
![GitHub License](https://img.shields.io/github/license/extism/extism)
# Extism Python PDK ![GitHub License](https://img.shields.io/github/license/extism/extism)
![GitHub release (with filter)](https://img.shields.io/github/v/release/extism/python-pdk)

This project contains a tool that can be used to create [Extism Plug-ins](https://extism.org/docs/concepts/plug-in) in Python.
Expand Down Expand Up @@ -132,6 +131,28 @@ extism call plugin.wasm sum --input='{"a": 20, "b": 21}' --wasi
# => {"sum":41}
```

You can also specify your input and output types as dataclasses using `extism.Json`:

```python
from typing import Optional, List
from dataclasses import dataclass

# ...

@dataclass
class User(extism.Json):
admin: bool
name: Optional[str]
email: str
addresses: List[Address]


@extism.plugin_fn
def reflect_user():
input = extism.input(User)
extism.output(input)
```

### Configs

Configs are key-value pairs that can be passed in by the host when creating a
Expand Down

0 comments on commit b2dcee7

Please sign in to comment.