Skip to content

Commit 91d5472

Browse files
committed
Increase cdd-* suite conformance
1 parent 0716888 commit 91d5472

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
//! # CDD CLI
66
//!
7-
//! Command Line Interface for the Contract-Driven Development toolchain.
7+
//! Command Line Interface for the Compiler Driven Development toolchain.
88
//!
99
//! Supported Commands:
1010
//! - `sync`: Pipeline DB -> Diesel -> Model -> Schema -> OpenAPI.

cli/src/to_openapi.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ use walkdir::WalkDir;
1111
#[derive(Args, Debug)]
1212
pub struct ToOpenApiArgs {
1313
/// Path to the code directory or file to parse.
14-
#[clap(short = 'f', long, env = "CDD_FILE")]
15-
pub file: PathBuf,
14+
#[clap(short = 'i', long, env = "CDD_INPUT")]
15+
pub input: PathBuf,
1616

1717
/// Output file for the generated OpenAPI spec.
1818
#[clap(short = 'o', long, env = "CDD_OUTPUT", default_value = "spec.json")]
1919
pub output: PathBuf,
2020
}
2121

2222
pub fn execute(args: &ToOpenApiArgs, target: &TargetMode) -> AppResult<()> {
23-
println!("Extracting OpenAPI specification from {:?}", args.file);
23+
println!("Extracting OpenAPI specification from {:?}", args.input);
2424

25-
if !args.file.exists() {
25+
if !args.input.exists() {
2626
return Err(AppError::General(format!(
2727
"Path not found: {:?}",
28-
args.file
28+
args.input
2929
)));
3030
}
3131

3232
let mut parsed_models = Vec::new();
3333
let mut parsed_routes = Vec::new();
3434

3535
// Walk directory and parse models and routes
36-
let walker = WalkDir::new(&args.file).into_iter();
36+
let walker = WalkDir::new(&args.input).into_iter();
3737
for entry in walker.filter_map(|e| e.ok()) {
3838
let path = entry.path();
3939
if path.extension().is_some_and(|ext| ext == "rs") {
@@ -120,7 +120,7 @@ mod tests {
120120
.unwrap();
121121

122122
let args = ToOpenApiArgs {
123-
file: src_dir,
123+
input: src_dir,
124124
output: dir.path().join("spec.json"),
125125
};
126126

@@ -131,7 +131,7 @@ mod tests {
131131
#[test]
132132
fn test_to_openapi_file_not_found() {
133133
let args = ToOpenApiArgs {
134-
file: PathBuf::from("does_not_exist_dir"),
134+
input: PathBuf::from("does_not_exist_dir"),
135135
output: PathBuf::from("spec.json"),
136136
};
137137
let result = execute(&args, &TargetMode::Server);
@@ -158,7 +158,7 @@ mod tests {
158158
.unwrap();
159159

160160
let args = ToOpenApiArgs {
161-
file: src_dir.clone(),
161+
input: src_dir.clone(),
162162
output: dir.path().join("spec.json"),
163163
};
164164

@@ -187,7 +187,7 @@ mod tests {
187187
std::fs::write(&input_file, handler_code).unwrap();
188188

189189
let args = ToOpenApiArgs {
190-
file: input_file,
190+
input: input_file,
191191
output: output_file.clone(),
192192
};
193193

@@ -212,7 +212,7 @@ mod tests {
212212
std::fs::write(&input_file, handler_code).unwrap();
213213

214214
let args = ToOpenApiArgs {
215-
file: input_file,
215+
input: input_file,
216216
output: std::path::PathBuf::from("/nonexistent_dir/output.yaml"),
217217
};
218218

core/src/openapi/parse/schemas/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ pub fn parse_openapi_spec_with_registry(
117117
let openapi: OpenApi = serde_json::from_value(json_val)
118118
.map_err(|e| AppError::General(format!("Failed to parse OpenAPI AST: {}", e)))?;
119119

120+
let default_components = utoipa::openapi::Components::new();
120121
let components = openapi
121122
.components
122123
.as_ref()
123-
.ok_or_else(|| AppError::General("No components found in OpenAPI spec".into()))?;
124+
.unwrap_or(&default_components);
124125

125126
// 4. Initialize Resolution Context with Base URI ($self) from original Shim
126127
// If $self defined in Shim, use it as Base URI.

0 commit comments

Comments
 (0)