Empty api list after importing an OpenAPI definition through Dashboard API

Branch/Environment/Version

  • Branch/Version: Stable/3.1.2
  • Environment: Tyk Cloud

Describe the bug
the "Created APIs page in the Tyk dashboards is empty, after importing an OpenAPI definition via the Dashboard API endpoint ‘/api/import/swagger/’. The imported api is visible using the endpoint ‘/api/apis/’ but not on browser interface

Reproduction steps
Steps to reproduce the behaviour:

  1. Create an api through the dashboard interface
  2. Import a second api using the Dashboard API ‘/api/import/swagger/’
  3. Go to System Management → APIs

Actual behaviour
Go to System Management → APIs → no api is listed

Expected behaviour
Go to System Management → APIs → all created and imported apis are listed

Screenshots/Video

Hey!

Did you include an “org_id” in the request payload? Please make sure it matches the one you see in the UI. You can see the org_id in your user profile through the control plane, next to your API key.

the import endpoint doens’t have the org_id field

POST /api/import/swagger/
Host: localhost:3000
authorization:7a7b140f-2480-4d5a-4e78-24049e3ba7f8
{
“swagger”: “{swagger data…}”,
“insert_into_api”: false,
“api_id”: “internal API id”,
“version_name”: “yourversionname”,
“upstream_url”: “yourupstreamurl”
}

hey @sedky did you had the chance to look into it?
Thanks!

Hi,
I just tried using tyk-demo and it worked.
Have you escaped the json?
Can you please send us the request and response you used?

This was mine:

curl --location --request POST ‘http://tyk-dashboard.localhost:3000/api/import/swagger
–header ‘Authorization: 082c97f3a35d442b511aa6fcc74a5829’
–header ‘Content-Type: text/plain’
–data-raw ‘{
“swagger”: “{\r\n “swagger”: “2.0”,\r\n “info”: {\r\n “title”: “yaara.httpbin.org”,\r\n “description”: “yaara API Management facade for a very handy and free online HTTP tool.”,\r\n “version”: “1.0”\r\n },\r\n “host”: “httpbin.org”,\r\n “schemes”: [\r\n “http”,\r\n “https”\r\n ],\r\n “paths”: {\r\n “/status/{code}”: {\r\n “get”: {\r\n “description”: “Returns provided HTTP Status code.”,\r\n “operationId”: “/status”,\r\n “parameters”: [{\r\n “name”: “code”,\r\n “in”: “path”,\r\n “description”: “HTTP code to return.”,\r\n “required”: true,\r\n “type”: “number”,\r\n “default”: 200,\r\n “enum”: [\r\n 200\r\n ]\r\n }],\r\n “responses”: {}\r\n }\r\n },\r\n “/get”: {\r\n “get”: {\r\n “description”: “Returns GET data.”,\r\n “operationId”: “/get”,\r\n “responses”: {}\r\n }\r\n },\r\n “/post”: {\r\n “post”: {\r\n “description”: “Returns POST data.”,\r\n “operationId”: “/post”,\r\n “responses”: {}\r\n }\r\n },\r\n “/patch”: {\r\n “patch”: {\r\n “description”: “Returns PATCH data.”,\r\n “operationId”: “/patch”,\r\n “responses”: {}\r\n }\r\n },\r\n “/put”: {\r\n “put”: {\r\n “description”: “Returns PUT data.”,\r\n “operationId”: “/put”,\r\n “responses”: {}\r\n }\r\n },\r\n “/delete”: {\r\n “delete”: {\r\n “description”: “Returns DELETE data.”,\r\n “operationId”: “/delete”,\r\n “responses”: {}\r\n }\r\n },\r\n “/xml”: {\r\n “get”: {\r\n “description”: “Returns some XML.”,\r\n “operationId”: “/xml”,\r\n “responses”: {}\r\n }\r\n },\r\n “/ip”: {\r\n “get”: {\r\n “description”: “Returns origin IP.”,\r\n “operationId”: “/ip”,\r\n “responses”: {}\r\n }\r\n },\r\n “/user-agent”: {\r\n “get”: {\r\n “description”: “Returns user agent string.”,\r\n “operationId”: “/user-agent”,\r\n “responses”: {}\r\n }\r\n },\r\n “/headers”: {\r\n “get”: {\r\n “description”: “Returns headers dictionary.”,\r\n “operationId”: “/headers”,\r\n “responses”: {}\r\n }\r\n },\r\n “/delay/{seconds}”: {\r\n “get”: {\r\n “description”: “Delays responding for n\u201310 seconds.”,\r\n “operationId”: “/delay”,\r\n “parameters”: [{\r\n “name”: “seconds”,\r\n “in”: “path”,\r\n “description”: “”,\r\n “required”: true,\r\n “type”: “string”,\r\n “default”: 2,\r\n “enum”: [\r\n 2\r\n ]\r\n }],\r\n “responses”: {}\r\n }\r\n },\r\n “/cache/{maxAge}”: {\r\n “get”: {\r\n “operationId”: “/cache”,\r\n “description”: “Sets a Cache-Control header for n seconds.”,\r\n “parameters”: [{\r\n “name”: “maxAge”,\r\n “in”: “path”,\r\n “description”: “”,\r\n “required”: true,\r\n “type”: “string”,\r\n “default”: 10,\r\n “enum”: [\r\n 10\r\n ]\r\n }],\r\n “responses”: {}\r\n }\r\n },\r\n “/uuid”: {\r\n “get”: {\r\n “operationId”: “/uuid”,\r\n “description”: “Returns UUID4.”,\r\n “responses”: {}\r\n }\r\n },\r\n “/anything”: {\r\n “get”: {\r\n “operationId”: “/anything”,\r\n “description”: “Returns request data, including method used.”,\r\n “responses”: {}\r\n }\r\n },\r\n “/gzip”: {\r\n “get”: {\r\n “operationId”: “/gzip”,\r\n “description”: “Returns gzip-encoded data.”,\r\n “responses”: {}\r\n }\r\n },\r\n “/base64/{value}”: {\r\n “get”: {\r\n “operationId”: “/base64”,\r\n “description”: “Decodes base64url-encoded string.”,\r\n “parameters”: [{\r\n “name”: “value”,\r\n “in”: “path”,\r\n “description”: “Base64 encoded string.”,\r\n “required”: true,\r\n “type”: “string”,\r\n “default”: “aGVsbG8gd29ybGQNCg%3D%3D”\r\n }],\r\n “responses”: {}\r\n }\r\n },\r\n “/deflate”: {\r\n “get”: {\r\n “operationId”: “/deflate”,\r\n “description”: “Returns deflate-encoded data.”,\r\n “responses”: {}\r\n }\r\n },\r\n “/brotli”: {\r\n “get”: {\r\n “operationId”: “/brotli”,\r\n “description”: “Returns brotli-encoded data.”,\r\n “responses”: {}\r\n }\r\n },\r\n “/response-headers”: {\r\n “get”: {\r\n “operationId”: “/response-headers”,\r\n “description”: “Returns key-value query parameters as response headers.”,\r\n “responses”: {}\r\n }\r\n },\r\n “/bytes/{number}”: {\r\n “get”: {\r\n “operationId”: “/bytes”,\r\n “description”: “Generates n random bytes of binary data”,\r\n “parameters”: [{\r\n “name”: “number”,\r\n “in”: “path”,\r\n “description”: “Number of bytes to return.”,\r\n “required”: true,\r\n “type”: “string”,\r\n “default”: “1024”\r\n }],\r\n “responses”: {}\r\n }\r\n },\r\n “/redirect-to”: {\r\n “get”: {\r\n “operationId”: “/redirect-to”,\r\n “description”: “302 redirects to a URL provided in query”,\r\n “parameters”: [{\r\n “name”: “url”,\r\n “in”: “query”,\r\n “description”: “Redirect target”,\r\n “required”: true,\r\n “type”: “string”,\r\n “default”: “http://example.com”\r\n }],\r\n “responses”: {}\r\n }\r\n },\r\n “/stream/{number}”: {\r\n “get”: {\r\n “operationId”: “/stream”,\r\n “description”: “Streams min(number, 100) lines.”,\r\n “parameters”: [{\r\n “name”: “number”,\r\n “in”: “path”,\r\n “description”: “Number of lines to stream.”,\r\n “required”: true,\r\n “type”: “number”,\r\n “default”: “10”\r\n }],\r\n “responses”: {}\r\n }\r\n }\r\n }\r\n}”,
“insert_into_api”: false,
“api_id”: “my-api-id”,
“version_name”: “v1.1”,
“upstream_url”: “http://httpbin.org
}’

{
“Status”: “OK”,
“Message”: “API imported”,
“Meta”: “60e5f3be42d9310001571f8e”
}