From e89c7207e5ba80dd4cb96c613ce95d1b41181beb Mon Sep 17 00:00:00 2001 From: Zhicheng Zhang Date: Tue, 29 Oct 2024 15:19:31 +0800 Subject: [PATCH] Bug/openapi support yaml (#596) --- apps/agentfabric/server.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/agentfabric/server.py b/apps/agentfabric/server.py index cb6eb2c2..baa9f35e 100644 --- a/apps/agentfabric/server.py +++ b/apps/agentfabric/server.py @@ -569,18 +569,23 @@ def openapi_schema_parser(uuid_str): params_str = request.get_data(as_text=True) params = json.loads(params_str) openapi_schema = params.get('openapi_schema') - host = openapi_schema.get('host', '') - basePath = openapi_schema.get('basePath', '') - if host and basePath: - return make_response( - jsonify({ - 'success': False, - 'status': 429, - 'message': 'The Swagger 2.0 format is not support, ' - 'please convert it to OpenAPI 3.0 format at https://petstore.swagger.io/', - 'request_id': request_id_var.get('') - }), 429) try: + if isinstance(openapi_schema, dict): + host = openapi_schema.get('host', '') + basePath = openapi_schema.get('basePath', '') + if host and basePath: + return make_response( + jsonify({ + 'success': + False, + 'status': + 429, + 'message': + 'The Swagger 2.0 format is not support, ' + 'please convert it to OpenAPI 3.0 format at https://petstore.swagger.io/', + 'request_id': + request_id_var.get('') + }), 429) if not isinstance(openapi_schema, dict): openapi_schema = json.loads(openapi_schema) except json.decoder.JSONDecodeError: