Can't import a Swagger file
alexiri opened this issue · comments
Describe the bug
Importing a swagger file while creating a copilot fails with no error. The copilot is left with no APIs, they can't be edited after the fact (#47) and it also can't be deleted (#447).
To Reproduce
Steps to reproduce the behavior:
- Go to the main page
- Click on 'Create Copilot'
- Give it a name in step 2 of the wizard
- In step 3, import the swagger file from https://petstore.swagger.io/
- Watch how nothing happens.
Expected behavior
The swagger file should be imported.
Screenshots
The console shows the following errors:
The response from that 404 request is the following:
{"is_error":true,"message":"Failed to parse Swagger file: No servers found in Swagger data."}
The swagger file does have a server specified, though:
"host":"petstore.swagger.io"
Here I am assuming that the swagger file from swagger.io is in fact correctly formed, but given that they're the standardizing body, I think it's a fair assumption.
Desktop (please complete the following information):
- OS: Linux
- Browser: Firefox
- Version: 121.0
Hi @alexiri thanks for raising this!
The parser only supports OpenAPI 3.0 which relies on servers
to get the base URL, I think hosts
is used in OpenAPI 2.0.
I will ship a change to make it more apparent in the error message, in the meanwhile maybe you can take a look here https://github.com/openchatai/OpenCopilot/blob/main/llm-server/utils/swagger_parser.py#L150 , I think if we added another check for hosts
it will work! because the rest is the same between 3.0 and 2.0.
For the delete part, I will take a look at it today.
Also, @alexiri when you download the swagger file from petstore, it doesn't have the full server url. Please set it up like this
@ah7255703 The error is not being displayed on the frontend when swagger parsing fails