Apicurio / apicurio-studio

Open Source API Design
https://www.apicur.io/studio/
Apache License 2.0
988 stars 495 forks source link

Import of Yaml api leads to connection lost #2170

Open aj84276 opened 1 year ago

aj84276 commented 1 year ago

Using : 0.2.54.Final

When importing an api from yaml file. leads to connection lost. But able to upload api using json..

image

image

zba commented 3 months ago

For me, version 1.0.0 installed from docker latest, it not loose connection but seems completely forget to convert yaml to json, because there are errors like: SyntaxError: Unexpected token 'o', "openapi: 3"... is not valid JSON and in _editor_::[ConfigService] Editing Info received from parent frame log there is unparsed yaml in content.value

I importing https://petstore3.swagger.io/api/v3/openapi.yaml to reproduce problem, it initially parses correct description (in import dialog), but later

_editor_::Error loading HTTP content: SyntaxError: Unexpected token 'o', "openapi: 3"... is not valid JSON
    at JSON.parse (<anonymous>)
    at i.initContent (main.0771e5ea4c4e26f1.js:1:2749568)
    at main.0771e5ea4c4e26f1.js:1:2749447
    at l.invoke (polyfills.e595e60a99d66bbb.js:1:18673)
    at Object.onInvoke (main.0771e5ea4c4e26f1.js:1:87413)
    at l.invoke (polyfills.e595e60a99d66bbb.js:1:18613)
    at I.run (polyfills.e595e60a99d66bbb.js:1:14006)
    at polyfills.e595e60a99d66bbb.js:1:25047
    at l.invokeTask (polyfills.e595e60a99d66bbb.js:1:19291)
    at Object.onInvokeTask (main.0771e5ea4c4e26f1.js:1:87229)
patramsey commented 3 months ago

For me, version 1.0.0 installed from docker latest, it not loose connection but seems completely forget to convert yaml to json, because there are errors like: SyntaxError: Unexpected token 'o', "openapi: 3"... is not valid JSON and in _editor_::[ConfigService] Editing Info received from parent frame log there is unparsed yaml in content.value

I importing https://petstore3.swagger.io/api/v3/openapi.yaml to reproduce problem, it initially parses correct description (in import dialog), but later

_editor_::Error loading HTTP content: SyntaxError: Unexpected token 'o', "openapi: 3"... is not valid JSON
    at JSON.parse (<anonymous>)
    at i.initContent (main.0771e5ea4c4e26f1.js:1:2749568)
    at main.0771e5ea4c4e26f1.js:1:2749447
    at l.invoke (polyfills.e595e60a99d66bbb.js:1:18673)
    at Object.onInvoke (main.0771e5ea4c4e26f1.js:1:87413)
    at l.invoke (polyfills.e595e60a99d66bbb.js:1:18613)
    at I.run (polyfills.e595e60a99d66bbb.js:1:14006)
    at polyfills.e595e60a99d66bbb.js:1:25047
    at l.invokeTask (polyfills.e595e60a99d66bbb.js:1:19291)
    at Object.onInvokeTask (main.0771e5ea4c4e26f1.js:1:87229)

@zba I had this same issue. Your file is YAML? Have you tried converting it to json with something like https://editor.swagger.io/ and trying again ? Maybe 1.0 doesn't support yaml syntax?

zba commented 3 months ago

@zba I had this same issue. Your file is YAML? Have you tried converting it to json with something like https://editor.swagger.io/ and trying again ? Maybe 1.0 doesn't support yaml syntax?

O'c it works with json :) I reporting broken yaml import. My file is demo from petstore :)

captn3m0 commented 3 weeks ago

Facing the same issue with YAML imports. It imports correctly, and the metadata is editable, but trying to load the API page results in:

editor_::Error loading HTTP content:  SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
    initContent http://localhost:8888/editors/main.0771e5ea4c4e26f1.js:1
    i http://localhost:8888/editors/main.0771e5ea4c4e26f1.js:1
    invoke http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    onInvoke http://localhost:8888/editors/main.0771e5ea4c4e26f1.js:1
    invoke http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    run http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    o http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    invokeTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    onInvokeTask http://localhost:8888/editors/main.0771e5ea4c4e26f1.js:1
    invokeTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    runTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    x http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    invokeTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    w http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    A http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    U http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    Y http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    scheduleTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    onScheduleTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    scheduleTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    scheduleTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    scheduleEventTask http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    u http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    set http://localhost:8888/editors/polyfills.e595e60a99d66bbb.js:1
    i http://localhost:8888/editors/main.0771e5ea4c4e26f1.js:1
    fac http://localhost:8888/editors/main.0771e5ea4c4e26f1.js:1

The /apis/studio/v1/designs/:UUID/content API is returning a base64 encoded version of the YAML file, which the frontend is trying to decode as JSON instead of YAML.