openchatai / OpenCopilot

🤖 🔥 Language-to-actions engine

Home Page:https://opencopilot.so

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Go to the main page
  2. Click on 'Create Copilot'
  3. Give it a name in step 2 of the wizard
  4. In step 3, import the swagger file from https://petstore.swagger.io/
  5. Watch how nothing happens.

Expected behavior
The swagger file should be imported.

Screenshots
The console shows the following errors:

image

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

Screenshot 2024-01-06 at 3 32 39 PM

@ah7255703 The error is not being displayed on the frontend when swagger parsing fails