124 lines
3.4 KiB
Rust
124 lines
3.4 KiB
Rust
use crank_core::{HttpMethod, RestTarget, ToolDescription, WizardState};
|
|
use crank_mapping::MappingSet;
|
|
use crank_schema::Schema;
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ImportFindingSeverity {
|
|
Info,
|
|
Warning,
|
|
Error,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub struct ImportFinding {
|
|
pub code: String,
|
|
pub severity: ImportFindingSeverity,
|
|
pub message: String,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub operation_key: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct ImportSourcePreview {
|
|
pub format: String,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub version: Option<String>,
|
|
pub title: String,
|
|
#[serde(default)]
|
|
pub servers: Vec<String>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct ImportPreview {
|
|
pub source: ImportSourcePreview,
|
|
pub groups: Vec<ImportGroupPreview>,
|
|
#[serde(default)]
|
|
pub findings: Vec<ImportFinding>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct ImportGroupPreview {
|
|
pub key: String,
|
|
pub title: String,
|
|
pub operations: Vec<ImportOperationCandidate>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct ImportOperationCandidate {
|
|
pub key: String,
|
|
pub method: HttpMethod,
|
|
pub path: String,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub operation_id: Option<String>,
|
|
pub suggested_name: String,
|
|
pub suggested_display_name: String,
|
|
pub description: String,
|
|
pub category: String,
|
|
pub input_fields: usize,
|
|
pub output_fields: usize,
|
|
#[serde(default)]
|
|
pub server_urls: Vec<String>,
|
|
#[serde(default)]
|
|
pub findings: Vec<ImportFinding>,
|
|
pub draft: RestImportCandidate,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct RestImportCandidate {
|
|
pub name: String,
|
|
pub display_name: String,
|
|
pub category: String,
|
|
pub target: RestTarget,
|
|
pub input_schema: Schema,
|
|
pub output_schema: Schema,
|
|
pub input_mapping: MappingSet,
|
|
pub output_mapping: MappingSet,
|
|
pub tool_description: ToolDescription,
|
|
pub wizard_state: Option<WizardState>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct RestImportDocument {
|
|
pub format: String,
|
|
pub version: Option<String>,
|
|
pub title: String,
|
|
pub servers: Vec<String>,
|
|
pub operations: Vec<RestImportOperation>,
|
|
pub findings: Vec<ImportFinding>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct RestImportOperation {
|
|
pub key: String,
|
|
pub method: HttpMethod,
|
|
pub path: String,
|
|
pub operation_id: Option<String>,
|
|
pub summary: Option<String>,
|
|
pub description: Option<String>,
|
|
pub tags: Vec<String>,
|
|
pub parameters: Vec<RestImportParameter>,
|
|
pub request_body_schema: Option<Value>,
|
|
pub response_schema: Option<Value>,
|
|
pub servers: Vec<String>,
|
|
pub findings: Vec<ImportFinding>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct RestImportParameter {
|
|
pub name: String,
|
|
pub location: RestParameterLocation,
|
|
pub required: bool,
|
|
pub description: Option<String>,
|
|
pub schema: Option<Value>,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum RestParameterLocation {
|
|
Path,
|
|
Query,
|
|
Header,
|
|
}
|