Skip to content

Commit

Permalink
added nullable=true to User->chatgpt_threads
Browse files Browse the repository at this point in the history
  • Loading branch information
dwdozier committed May 31, 2024
1 parent 0ed711a commit 8f58210
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/cloudtruth-restapi/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct User {
pub membership_id: Option<String>,
/// The threads this user is participating in with ChatGPT.
#[serde(rename = "chatgpt_threads")]
pub chatgpt_threads: ::std::collections::HashMap<String, serde_json::Value>, // TODO: One of these things is not like the others, why is this autogenerated as a required HashMap and not an <Option> Hashmap?
pub chatgpt_threads: Option<::std::collections::HashMap<String, serde_json::Value>>,
/// The user's role in the current organization (defined by the request authorization header).
#[serde(rename = "role")]
pub role: Option<String>,
Expand All @@ -49,7 +49,7 @@ impl User {
name: Option<String>,
organization_name: Option<String>,
membership_id: Option<String>,
chatgpt_threads: ::std::collections::HashMap<String, serde_json::Value>,
chatgpt_threads: Option<::std::collections::HashMap<String, serde_json::Value>>,
role: Option<String>,
email: Option<String>,
picture_url: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -21812,6 +21812,7 @@
"chatgpt_threads": {
"type": "object",
"additionalProperties": {},
"nullable": true,
"readOnly": true,
"description": "The threads this user is participating in with ChatGPT."
},
Expand Down
1 change: 1 addition & 0 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15358,6 +15358,7 @@ components:
description: Membership identifier for user.
chatgpt_threads:
type: object
nullable: true
additionalProperties: {}
readOnly: true
description: The threads this user is participating in with ChatGPT.
Expand Down
5 changes: 2 additions & 3 deletions src/database/user_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn default_user() -> &'static User {
picture_url: None,
created_at: "".to_string(),
modified_at: None,
chatgpt_threads: HashMap::new(), // TODO: Pretty sure this is because of a bug in the OpenAPI generator
chatgpt_threads: None,
})
}

Expand Down Expand Up @@ -184,9 +184,8 @@ mod test {

#[test]
fn service_account_null_last_used_by() {
let data = r#"{"count":1,"next":null,"previous":null,"results":[{"url":"https://api.staging.cloudtruth.io/api/v1/serviceaccounts/auth0%7C61949e36c0baff006a6d1aea/","id":"auth0|61949e36c0baff006a6d1aea","user":{"url":"https://api.staging.cloudtruth.io/api/v1/users/auth0%7C61949e36c0baff006a6d1aea/","id":"auth0|61949e36c0baff006a6d1aea","type":"service","name":"test-user-name-Linux-37","email":"serviceaccount+ajwflw8wzpc1quhp@cloudtruth.com","picture_url":null,"created_at":"2021-11-17T06:16:24.082794Z","modified_at":"2021-11-17T06:16:24.548713Z","chatgpt_threads":{},"description":"Description on create",created_at":"2021-11-17T06:16:24.558748Z","modified_at":"2021-11-17T06:16:24.558748Z","last_used_at":null}]}"#;
let data = r#"{"count":1,"next":null,"previous":null,"results":[{"url":"https://api.staging.cloudtruth.io/api/v1/serviceaccounts/auth0%7C61949e36c0baff006a6d1aea/","id":"auth0|61949e36c0baff006a6d1aea","user":{"url":"https://api.staging.cloudtruth.io/api/v1/users/auth0%7C61949e36c0baff006a6d1aea/","id":"auth0|61949e36c0baff006a6d1aea","type":"service","name":"test-user-name-Linux-37","email":"serviceaccount+ajwflw8wzpc1quhp@cloudtruth.com","picture_url":null,"created_at":"2021-11-17T06:16:24.082794Z","modified_at":"2021-11-17T06:16:24.548713Z","chatgpt_threads":{"foo":{"bar": "baz"}},"description":"Description on create",created_at":"2021-11-17T06:16:24.558748Z","modified_at":"2021-11-17T06:16:24.558748Z","last_used_at":null}]}"#;
let result: serde_json::Result<PaginatedServiceAccountList> = serde_json::from_str(data);
println!("{:?}", result);
assert!(result.is_ok());
let list = result.unwrap();
assert_eq!(1, list.count.unwrap_or(-1));
Expand Down

0 comments on commit 8f58210

Please sign in to comment.