vapi_client/models/json_schema.rs
1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct JsonSchema {
17 /// This is the type of output you'd like. `string`, `number`, `integer`, `boolean` are the primitive types and should be obvious. `array` and `object` are more interesting and quite powerful. They allow you to define nested structures. For `array`, you can define the schema of the items in the array using the `items` property. For `object`, you can define the properties of the object using the `properties` property.
18 #[serde(rename = "type")]
19 pub r#type: Type,
20 /// This is required if the type is \"array\". This is the schema of the items in the array. This is of type JsonSchema. However, Swagger doesn't support circular references.
21 #[serde(rename = "items", skip_serializing_if = "Option::is_none")]
22 pub items: Option<serde_json::Value>,
23 /// This is required if the type is \"object\". This specifies the properties of the object. This is a map of string to JsonSchema. However, Swagger doesn't support circular references.
24 #[serde(rename = "properties", skip_serializing_if = "Option::is_none")]
25 pub properties: Option<serde_json::Value>,
26 /// This is the description to help the model understand what it needs to output.
27 #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
28 pub description: Option<String>,
29 /// This is a list of properties that are required. This only makes sense if the type is \"object\".
30 #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
31 pub required: Option<Vec<String>>,
32 /// This is a regex that will be used to validate data in question.
33 #[serde(rename = "regex", skip_serializing_if = "Option::is_none")]
34 pub regex: Option<String>,
35 /// This the value that will be used in filling the property.
36 #[serde(rename = "value", skip_serializing_if = "Option::is_none")]
37 pub value: Option<String>,
38 /// This the target variable that will be filled with the value of this property.
39 #[serde(rename = "target", skip_serializing_if = "Option::is_none")]
40 pub target: Option<String>,
41 /// This array specifies the allowed values that can be used to restrict the output of the model.
42 #[serde(rename = "enum", skip_serializing_if = "Option::is_none")]
43 pub r#enum: Option<Vec<String>>,
44}
45
46impl JsonSchema {
47 pub fn new(r#type: Type) -> JsonSchema {
48 JsonSchema {
49 r#type,
50 items: None,
51 properties: None,
52 description: None,
53 required: None,
54 regex: None,
55 value: None,
56 target: None,
57 r#enum: None,
58 }
59 }
60}
61/// This is the type of output you'd like. `string`, `number`, `integer`, `boolean` are the primitive types and should be obvious. `array` and `object` are more interesting and quite powerful. They allow you to define nested structures. For `array`, you can define the schema of the items in the array using the `items` property. For `object`, you can define the properties of the object using the `properties` property.
62#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
63pub enum Type {
64 #[serde(rename = "string")]
65 String,
66 #[serde(rename = "number")]
67 Number,
68 #[serde(rename = "integer")]
69 Integer,
70 #[serde(rename = "boolean")]
71 Boolean,
72 #[serde(rename = "array")]
73 Array,
74 #[serde(rename = "object")]
75 Object,
76}
77
78impl Default for Type {
79 fn default() -> Type {
80 Self::String
81 }
82}