@@ -99,7 +99,7 @@ def generate_docs_json(
9999
100100 out_json = json .dumps (output , indent = 2 )
101101 if output_file :
102- Path (output_file ).write_text (out_json , encoding = "utf-8" )
102+ Path (output_file ).write_text (out_json + " \n " , encoding = "utf-8" )
103103 else :
104104 print (out_json )
105105
@@ -168,7 +168,12 @@ def process_from_openapi(
168168 """Process from_openapi subcommands."""
169169 if not output_dir :
170170 output_dir = "."
171- out_dir = Path (output_dir )
171+ out_path = Path (output_dir )
172+ if out_path .suffix : # It's a file path
173+ out_dir = out_path .parent
174+ else :
175+ out_dir = out_path
176+
172177 out_dir .mkdir (parents = True , exist_ok = True )
173178
174179 if input_path :
@@ -196,10 +201,21 @@ def process_from_openapi(
196201 (out_dir / "client.py" ).write_text (
197202 generator .generate_code (), encoding = "utf-8"
198203 )
204+ from openapi_client .cli_sdk_cdd .emit import emit_cli_sdk
205+
199206 (out_dir / "cli_main.py" ).write_text (emit_cli_sdk (spec ), encoding = "utf-8" )
200207 elif subcommand == "to_server" :
201- mock_module = emit_mock_server (spec )
202- (out_dir / "mock_server.py" ).write_text (mock_module .code , encoding = "utf-8" )
208+ from openapi_client .fastapi .emit import emit_fastapi
209+ from openapi_client .sqlalchemy_cdd .emit import emit_sqlalchemy
210+
211+ # Emit FastAPI server
212+ fastapi_code = emit_fastapi (spec )
213+ (out_dir / "main.py" ).write_text (fastapi_code , encoding = "utf-8" )
214+
215+ # Emit SQLAlchemy models
216+ sa_code = emit_sqlalchemy (spec )
217+ if sa_code :
218+ (out_dir / "models.py" ).write_text (sa_code , encoding = "utf-8" )
203219
204220 if not no_installable_package :
205221 scaffold_package (out_dir )
0 commit comments