Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Json Parsing Error management on OperationView.prototype.showStatus #555

Closed
sebadiaz opened this issue Sep 3, 2014 · 2 comments
Closed
Milestone

Comments

@sebadiaz
Copy link

sebadiaz commented Sep 3, 2014

In swagger-ui.js
the lines

 else if (contentType === "application/json" || /\+json$/.test(contentType)) {
        code = $('<code />').text(JSON.stringify(JSON.parse(content), null, "  "));
        pre = $('<pre class="json" />').append(code);
      }

need to replaced by

 } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
        var json="";
        try{
          json=JSON.parse(content)
        }catch(e)
        {
          json={"string":content};
        }
        code = $('<code />').text(JSON.stringify(json, null, "  "));
        pre = $('<pre class="json" />').append(code);
      }
@fehguy
Copy link
Contributor

fehguy commented Jan 28, 2015

OK but this is only because your server is lying about returning JSON. If you are returning non-parsable JSON, then you'll get an error.

@fehguy fehguy added this to the v2.1.0-M1 milestone Jan 28, 2015
@fehguy
Copy link
Contributor

fehguy commented Jan 31, 2015

this has been added in develop_2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants