| | import json |
| | import gradio as gr |
| | import tempfile |
| | import os |
| |
|
| | def update_swagger(swagger_content): |
| | try: |
| | |
| | swagger_data = json.loads(swagger_content) |
| | |
| | |
| | swagger_data['info'] = { |
| | "title": "My API", |
| | "version": "1.0.0", |
| | "description": "Your API description" |
| | } |
| | |
| | |
| | updated_swagger = json.dumps(swagger_data, indent=2) |
| | |
| | |
| | temp_file_path = os.path.join(tempfile.gettempdir(), "updatedswagger.json") |
| | with open(temp_file_path, "w", encoding="utf-8") as temp_file: |
| | temp_file.write(updated_swagger) |
| | |
| | return updated_swagger, temp_file_path |
| | except Exception as e: |
| | return f"Error updating swagger.json: {e}", None |
| |
|
| | demo = gr.Interface( |
| | fn=update_swagger, |
| | inputs=gr.Textbox(lines=20, label="Input Swagger JSON"), |
| | outputs=[gr.Textbox(lines=20, label="Updated Swagger JSON"), gr.File(label="Download Updated JSON")] |
| | ) |
| |
|
| | demo.launch() |