Skip to content

Commit 196f2ab

Browse files
committed
functions handling logic refine
1 parent ef178bf commit 196f2ab

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/serverless_openapi_generator/pydantic_handler.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,16 @@ def generate_serverless_config(successfully_generated_schemas, project_meta, pro
223223
documentation_block["contact"]["email"] = project_meta["contact_email"]
224224

225225
functions_file = project_root / "serverless" / "functions.yml"
226-
functions_ref = f"${{file(./serverless/functions.yml)}}" if functions_file.exists() else {}
226+
functions_content = {}
227+
if functions_file.exists():
228+
try:
229+
with open(functions_file, "r") as f:
230+
functions_content = yaml.safe_load(f)
231+
print(f" Successfully loaded functions from {functions_file}")
232+
except Exception as e:
233+
print(f" Warning: Could not read or parse functions file {functions_file}: {e}")
234+
else:
235+
print(" Warning: functions.yml not found. No operations will be generated.")
227236

228237

229238
config_content = {
@@ -235,7 +244,7 @@ def generate_serverless_config(successfully_generated_schemas, project_meta, pro
235244
"documentation": documentation_block,
236245
"variables": {"lambda_warm_instances": 1, "lambda_memory_size": 256},
237246
},
238-
"functions": functions_ref,
247+
"functions": functions_content,
239248
}
240249

241250
return config_content

0 commit comments

Comments
 (0)