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};
12use utoipa::ToSchema;
13
14
15use crate::models;
16
17#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
18pub struct JsonSchema {
19 /// 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.
20 #[serde(rename = "type")]
21 pub r#type: Type,
22 /// 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.
23 #[serde(rename = "items", skip_serializing_if = "Option::is_none")]
24 pub items: Option<serde_json::Value>,
25 /// 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.
26 #[serde(rename = "properties", skip_serializing_if = "Option::is_none")]
27 pub properties: Option<serde_json::Value>,
28 /// This is the description to help the model understand what it needs to output.
29 #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
30 pub description: Option<String>,
31 /// This is a list of properties that are required. This only makes sense if the type is \"object\".
32 #[serde(rename = "required", skip_serializing_if = "Option::is_none")]
33 pub required: Option<Vec<String>>,
34 /// This is a regex that will be used to validate data in question.
35 #[serde(rename = "regex", skip_serializing_if = "Option::is_none")]
36 pub regex: Option<String>,
37 /// This the value that will be used in filling the property.
38 #[serde(rename = "value", skip_serializing_if = "Option::is_none")]
39 pub value: Option<String>,
40 /// This the target variable that will be filled with the value of this property.
41 #[serde(rename = "target", skip_serializing_if = "Option::is_none")]
42 pub target: Option<String>,
43 /// This array specifies the allowed values that can be used to restrict the output of the model.
44 #[serde(rename = "enum", skip_serializing_if = "Option::is_none")]
45 pub r#enum: Option<Vec<String>>,
46}
47
48impl JsonSchema {
49 pub fn new(r#type: Type) -> JsonSchema {
50 JsonSchema {
51 r#type,
52 items: None,
53 properties: None,
54 description: None,
55 required: None,
56 regex: None,
57 value: None,
58 target: None,
59 r#enum: None,
60 }
61 }
62}
63/// 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.
64#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
65pub enum Type {
66 #[serde(rename = "string")]
67 String,
68 #[serde(rename = "number")]
69 Number,
70 #[serde(rename = "integer")]
71 Integer,
72 #[serde(rename = "boolean")]
73 Boolean,
74 #[serde(rename = "array")]
75 Array,
76 #[serde(rename = "object")]
77 Object,
78}
79
80impl Default for Type {
81 fn default() -> Type {
82 Self::String
83 }
84}