Skip to main content

How to fix "400 Missing servers on OAS" when adding a new API?

What's a 400: Missing servers on OAS error?

If you have this error when you're adding a new API, that mean no servers has been configured inside your OpenAPI / Swagger file (OAS).

Server's information are needed because only relative endpoints are described inside an OpenAPI file, and we need to know which server we have to contact to send the request.

Most of the time, server's URL are "static" (ex: https://googleapis.com) but they can me also dynamic (ex: https://mycompany.shopify.com)

How to fix this error?

You'll have to edit your OpenAPI file. You can use an online tool like Swagger Editor, a desktop tool like Stoplight or even a simple text editor is you know the OpenAPI syntax 😉.

Once you have open this file, you have to add a JSON array like this on the top level of your OpenAPI file (at the same level of infos and paths):

"servers": [
{
"url": "https://api.example.com",
},
],

If you want to have configurable variables inside this URL, you can design a array like this:

"servers": [
{
"url": "https://{mycompany}.crm.com",
"variables": {
"mycompany": {
"default": "ACME"
}
}
},
],

Here a real world example of server's definition inside the Quickbooks API:

"servers": [
{
"url": "https://quickbooks.api.intuit.com/v3/company/{companyid}",
"variables": {
"companyid": {
"default": "DefaultParameterValue"
}
}
},
{
"url": "https://sandbox-quickbooks.api.intuit.com/v3/company/{companyid}",
"variables": {
"companyid": {
"default": "DefaultParameterValue"
}
}
},
{
"url": "https://quickbooks.api.intuit.com/v3/company"
}
],

If you want more example, go on our API's catalog and download inside API's documentation tab a OpenAPI file to see how servers has been configured.