Skip to content

Commit

Permalink
minor pathlib fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahuljagwani committed Dec 15, 2023
1 parent c8e4090 commit 82d1e1d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions foca/api/register_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ def register_openapi(

# Write modified specs
try:
output_path = Path(spec.path_out)
root_dir = output_path.parent
file_name = output_path.name
temp_dir = Path(os.environ.get('TMPDIR', 'specs'))
modified_dir = root_dir / temp_dir
modified_dir.mkdir(parents=True, exist_ok=True)
spec.path_out = modified_dir / file_name
output_path = os.path.normpath(spec.path_out)
root_dir = os.path.dirname(output_path)
file_name = os.path.basename(output_path)
temp_dir = os.environ.get('TMPDIR', 'specs')
modified_dir = os.path.join(root_dir, temp_dir)
os.makedirs(modified_dir, exist_ok=True)
spec.path_out = os.path.join(modified_dir, file_name)

with open(spec.path_out, 'w') as out_file: # type: ignore
yaml.safe_dump(spec_parsed, out_file)
except OSError as e:
Expand Down

0 comments on commit 82d1e1d

Please sign in to comment.