Skip to content

Commit

Permalink
Fixed up last example for structs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanleomk committed Jul 8, 2024
1 parent 6729f6f commit b9fc0b7
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,57 @@ struct MaybeUser {
}
*/
```

### Nested Structs

We also support Nested Structs out of the box - see example below

```rust
#[derive(InstructMacro, Debug, Serialize, Deserialize)]
struct Address {
location: String,
distance: i32,
}

#[derive(InstructMacro, Debug, Serialize, Deserialize)]
struct User {
name: String,
age: u8,
address: Address,
}

/*
{
"type": "object",
"properties": {
"address": {
"type": "object",
"description": "",
"properties": {
"location": {
"type": "string",
"description": ""
},
"distance": {
"type": "number",
"description": ""
}
}
},
"name": {
"type": "string",
"description": ""
},
"age": {
"type": "number",
"description": ""
}
},
"required": [
"name",
"age",
"address"
]
}
*/
```

0 comments on commit b9fc0b7

Please sign in to comment.