apinf / platform

Apinf - Open source API management platform with multi proxy and protocol support
https://apinf.com/
European Union Public License 1.1
74 stars 33 forks source link

Swagger UI not able to load #3089

Closed kyyberi closed 6 years ago

kyyberi commented 6 years ago

Steps to Reproduce:

  1. go to page: https://apinf.io/apis/kunta-api
  2. Click documentation tab

Outcome:

screenshot at marraskuuta 02 09-06-16

Expected Behavior:

Load SwaggerUI

Environment:

Mac 10.12.6 , Chrome browser (l61.0.3163.100), APInf production site (https://apinf.io)

Nazarah commented 6 years ago

Tested in Windows 8 with Chrome (latest version) browser and was able to reproduce it. Found the following violation messages in the console view swaggeruiload

kyyberi commented 6 years ago

Swagger seems to be valid, but....

screenshot at marraskuuta 02 10-16-33
kyyberi commented 6 years ago

Might be related to

marla-singer commented 6 years ago

@kyyberi I fixedit via UI. Don't know what happened but I've got e-mail notification about error on the server side

SyntaxError: Error parsing "https://github.com/Metatavu/kunta-api-spec/blob/master/swagger.yaml" 
end of the stream or a document separator is expected at line 313, column 24:
      <!-- blob contrib key: blob_contributors:v21:d22dbc1c

and

RangeError: Maximum call stack size exceeded

Looks like the Swagger didn't parse the file and fall down with stack overflow

kyyberi commented 6 years ago

I'm not able to get it to load.

kyyberi commented 6 years ago

Problem still exists. This API is going to real use soon in one of our Smart city cases.

55 commented 6 years ago

Same thing locally. I tried via

Also getting in console:

raven@2.2.1 alert: unhandledRejection captured: 9e46c6e3f0464545b27ee3f5ad607068
raven@2.2.1 alert: unhandledRejection captured: de552699f6b849b7970ba00e38bb01e2
raven@2.2.1 alert: unhandledRejection captured: bb343e3441c843e2adc47aa471308957
raven@2.2.1 alert: unhandledRejection captured: 849e464fc1cf4edfbec7ab468e6ac4e2
raven@2.2.1 alert: unhandledRejection captured: e88479a4a7b84a77a7162d69718ea987
55 commented 6 years ago

Used URL https://raw.githubusercontent.com/Metatavu/kunta-api-spec/master/swagger.yaml @ http://petstore.swagger.io/. Perfectly works.

kyyberi commented 6 years ago

@55 that was the message from client as well.

krashna-deligence commented 6 years ago

Hi @55 i have checked this issue on "Google Chrome" and "mozilla" and i did't get this type of error . Please review below gifs firfox chrome

marla-singer commented 6 years ago

@kyyberi @55 It was link to the incorrect Swagger file with "circular references". The Swagger couldn't build the correct UI.

I went through entire file and resolved the circular references directly.

55 commented 6 years ago

@marla-singer any ideas why it worked at http://petstore.swagger.io?

marla-singer commented 6 years ago

@55 Nope. It needs detailed investigation

55 commented 6 years ago

@krashna-deligence interesting, what OS were you using?

krashna-deligence commented 6 years ago

ubantu 16.04

marla-singer commented 6 years ago

Investigation report

I thought the problem comes from library "swagger-parser":

  1. I upgraded the library "swagger-parser" to v4.0.0 and I've got the same result

  2. I went through the source code of library and didn't find any problem with a circular reference.

  3. README.md says:

    Supports circular references, nested references, back-references, and cross-references

  4. Anyway, the swagger-parser returns the correct result but the client side doesn't receive it.

The error trace displays that the problem comes from EJSON joxi_screenshot_1512570346016 1

I tried to catch the error with "Maximum call stack size exceeded" but no success. The circular reference is the invalid type of JSON and EJSON can't work as expected.

Didn't think up any good idea about how to fix it or notice a user about this error

Nazarah commented 6 years ago

Tested in https://staging.apinf.io (release 0.52). The problem exists there with APIs having swagger documentation. screenshot of the exception caught is attached.

Exception image

documentationtabload

cc @saransh-dev

saransh-dev commented 6 years ago

Yes, we need to check result also in onCreated at line number 33 inside apinf_packages/api_docs/swagger_ui/swagger_ui.js Currently we have like if (result.schemes && result.schemes[0] === 'http') { and we need to make it like if (result && result.schemes && result.schemes[0] === 'http') {

anarva commented 6 years ago

@preriasusi - I cannot reproduce this on apinf.io, which is where the original error was first found. The later comments on this bug report are referring to another bug which was reported and fixed in another report. Please check, and if you agree, close this issue.

kyyberi commented 6 years ago

In apinf.io kunta-api seems to load swagger

kunta-api
anarva commented 6 years ago

Thanks, closing..