swagger-api / swagger-api/swagger-ui

Parser error: Parser error on line 57 end of the stream or a document separator is expected

Open
#4,428 13 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: support
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

When I trying to use (local) swagger.json file I have got a problem with parsing/validating. Its working locally on http://localhost:8080/ but when I try to load the index.html file on browser it shown error: "Parser error: Parser error on line 57 end of the stream or a document separator is expected". I set "validatorUrl: null," in dist/index.html and fix CORS but problem is still exists. What is a problem here? Is there any configuration tips? It looks like Dist bug

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? V/3.13.3 (#4420)
Which Swagger-UI version?
How did you install Swagger-UI? Github download
Which browser & version? Chrome
Which operating system? Win10
Demonstration API definition - full swagger.json file
{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": "tytul",
    "contact": {
      "name": "mario",
      "email": "a@b.com"
    }
  },
  "host": "127.0.0.1:8080",
  "basePath": "/datasnap/rest/TServerMethods1/",
  "schemes": [
    "http"
  ],
  "paths": {
    "/test": {
      "get": {
        "description": "Main Desc",
        "parameters": [
          {
            "in": "query",
            "name": "some name",
            "description": "desc",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "some desc"
          }
        }
      }
    }
  }
}
Configuration (dist/swagger.json)
{
  window.onload = function() {
  
  // Build a system 
  const ui = SwaggerUIBundle({
    url: "./swagger.json",
    dom_id: '#swagger-ui',
    deepLinking: true,
	validatorUrl: null,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  })
  window.ui = ui
}
}
Expected Behavior
Current Behavior
Possible Solution
Context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dist/index.html configuration and the local swagger.json definition, then reproduce the parser error in Chrome using the supplied setup. Compare loading through localhost with opening the index.html directly and determine which documented behavior should apply. Done means the provided definition loads without the reported parser error or the issue is narrowed to an invalid input or unsupported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.