Skip to content

Commit 933e9ee

Browse files
committed
Cleanup code
1 parent 7d7087e commit 933e9ee

3 files changed

Lines changed: 0 additions & 153 deletions

File tree

crates/vespera_core/src/openapi.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,6 @@ impl OpenApi {
192192
}
193193
}
194194
}
195-
196-
/// Merge from a JSON string. Returns error if parsing fails.
197-
///
198-
/// # Errors
199-
///
200-
/// Returns a `serde_json::Error` when `json_str` is not valid JSON or does not
201-
/// deserialize into an `OpenApi` document.
202-
pub fn merge_from_str(&mut self, json_str: &str) -> Result<(), serde_json::Error> {
203-
let other: Self = serde_json::from_str(json_str)?;
204-
self.merge(other);
205-
Ok(())
206-
}
207195
}
208196

209197
#[cfg(test)]
@@ -460,35 +448,6 @@ mod tests {
460448
assert_eq!(base.tags.as_ref().unwrap().len(), 1);
461449
}
462450

463-
#[test]
464-
fn test_merge_from_str() {
465-
let mut base = create_base_openapi();
466-
base.paths
467-
.insert("/users".to_string(), create_path_item("Get users"));
468-
469-
let other_json = r#"{
470-
"openapi": "3.1.0",
471-
"info": { "title": "Other API", "version": "2.0.0" },
472-
"paths": {
473-
"/posts": { "get": { "summary": "Get posts", "responses": {} } }
474-
}
475-
}"#;
476-
477-
let result = base.merge_from_str(other_json);
478-
assert!(result.is_ok());
479-
assert!(base.paths.contains_key("/users"));
480-
assert!(base.paths.contains_key("/posts"));
481-
}
482-
483-
#[test]
484-
fn test_merge_from_str_invalid_json() {
485-
let mut base = create_base_openapi();
486-
let invalid_json = "{ invalid json }";
487-
488-
let result = base.merge_from_str(invalid_json);
489-
assert!(result.is_err());
490-
}
491-
492451
#[test]
493452
fn test_merge_empty_other() {
494453
let mut base = create_base_openapi();

crates/vespera_core/src/route.rs

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -236,32 +236,6 @@ impl PathItem {
236236
HttpMethod::Trace => self.trace = Some(operation),
237237
}
238238
}
239-
240-
/// Get an operation for a specific HTTP method
241-
#[must_use]
242-
pub const fn get_operation(&self, method: &HttpMethod) -> Option<&Operation> {
243-
match method {
244-
HttpMethod::Get => self.get.as_ref(),
245-
HttpMethod::Post => self.post.as_ref(),
246-
HttpMethod::Put => self.put.as_ref(),
247-
HttpMethod::Patch => self.patch.as_ref(),
248-
HttpMethod::Delete => self.delete.as_ref(),
249-
HttpMethod::Head => self.head.as_ref(),
250-
HttpMethod::Options => self.options.as_ref(),
251-
HttpMethod::Trace => self.trace.as_ref(),
252-
}
253-
}
254-
}
255-
256-
/// Route information (for internal use)
257-
#[derive(Debug, Clone)]
258-
pub struct RouteInfo {
259-
/// HTTP method
260-
pub method: HttpMethod,
261-
/// Path
262-
pub path: String,
263-
/// Operation information
264-
pub operation: Operation,
265239
}
266240

267241
#[cfg(test)]
@@ -404,65 +378,6 @@ mod tests {
404378
assert!(path_item.trace.is_some());
405379
}
406380

407-
#[test]
408-
fn test_path_item_get_operation() {
409-
let mut path_item = PathItem::default();
410-
411-
let operation = Operation {
412-
operation_id: Some("test_operation".to_string()),
413-
tags: None,
414-
summary: None,
415-
description: None,
416-
parameters: None,
417-
request_body: None,
418-
responses: BTreeMap::new(),
419-
security: None,
420-
};
421-
422-
// Initially, all operations should be None
423-
assert!(path_item.get_operation(&HttpMethod::Get).is_none());
424-
assert!(path_item.get_operation(&HttpMethod::Post).is_none());
425-
426-
// Set GET operation
427-
path_item.set_operation(HttpMethod::Get, operation.clone());
428-
let retrieved = path_item.get_operation(&HttpMethod::Get);
429-
assert!(retrieved.is_some());
430-
assert_eq!(
431-
retrieved.unwrap().operation_id,
432-
Some("test_operation".to_string())
433-
);
434-
435-
// Set POST operation
436-
let mut operation_post = operation.clone();
437-
operation_post.operation_id = Some("post_operation".to_string());
438-
path_item.set_operation(HttpMethod::Post, operation_post);
439-
let retrieved = path_item.get_operation(&HttpMethod::Post);
440-
assert!(retrieved.is_some());
441-
assert_eq!(
442-
retrieved.unwrap().operation_id,
443-
Some("post_operation".to_string())
444-
);
445-
446-
// Test all methods
447-
path_item.set_operation(HttpMethod::Put, operation.clone());
448-
assert!(path_item.get_operation(&HttpMethod::Put).is_some());
449-
450-
path_item.set_operation(HttpMethod::Patch, operation.clone());
451-
assert!(path_item.get_operation(&HttpMethod::Patch).is_some());
452-
453-
path_item.set_operation(HttpMethod::Delete, operation.clone());
454-
assert!(path_item.get_operation(&HttpMethod::Delete).is_some());
455-
456-
path_item.set_operation(HttpMethod::Head, operation.clone());
457-
assert!(path_item.get_operation(&HttpMethod::Head).is_some());
458-
459-
path_item.set_operation(HttpMethod::Options, operation.clone());
460-
assert!(path_item.get_operation(&HttpMethod::Options).is_some());
461-
462-
path_item.set_operation(HttpMethod::Trace, operation);
463-
assert!(path_item.get_operation(&HttpMethod::Trace).is_some());
464-
}
465-
466381
#[test]
467382
fn test_path_item_set_operation_overwrites() {
468383
let mut path_item = PathItem::default();

crates/vespera_core/src/schema.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,6 @@ pub enum SchemaType {
4848
Null,
4949
}
5050

51-
/// Number format
52-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
53-
#[serde(rename_all = "lowercase")]
54-
pub enum NumberFormat {
55-
Float,
56-
Double,
57-
Int32,
58-
Int64,
59-
}
60-
61-
/// String format
62-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63-
#[serde(rename_all = "lowercase")]
64-
pub enum StringFormat {
65-
Date,
66-
DateTime,
67-
Password,
68-
Byte,
69-
Binary,
70-
Email,
71-
Uuid,
72-
Uri,
73-
Hostname,
74-
IpV4,
75-
IpV6,
76-
}
77-
7851
/// Serialize `Option<f64>` as integer when the value has no fractional part.
7952
///
8053
/// Ensures OpenAPI JSON uses `0` instead of `0.0` for integer constraints like

0 commit comments

Comments
 (0)