arjun-g / vs-swagger-viewer

Swagger Viewer lets you preview and validate Swagger 2.0 and OpenAPI files as you type in Visual Studio Code.
MIT License
170 stars 47 forks source link

TypeError: Failed to fetch #23

Open arcotek-ltd opened 6 years ago

arcotek-ltd commented 6 years ago

In swagger hub, I do not get the error, however in your preview pane I do: Error

Is it to do with the XML?

The definition:

---
swagger: "2.0"
info:
  description: "OpenAPI for Abbyy's OCR SDK"
  version: "1.0.0"
  title: "AbbyyOCR"
  contact:
    email: "blah@blah.com"
host: "cloud.ocrsdk.com"
basePath: "/"
schemes:
- "https"
securityDefinitions:
  basicAuth:
    type: "basic"
security:
- basicAuth: []
paths:
  /getApplicationInfo:
    get:
      summary: "Gets information about the account"
      description: "This method allows you to receive information about the application type, its current balance and expiration date. You may find it helpful for keeping the usage records."
      operationId: "GetApplicationInfo"
      produces:
       - "application/xml"
      parameters: []
      responses:
        200:
          description: "Successful method call."
          schema:
            type: array
            items:
             properties:
              name:
               type: string
              pages:
               type: integer
              fields:
               type: integer
              expires:
               type: string
              type:
               type: string
        403:
          description: "The call to this method is disabled in your application settings."
  /processImage:
    post:
      summary: "Passes task for processing"
      description: "Loads the image, creates a processing task for the image with the specified parameters, and passes the task for processing."
      operationId: "ProcessImage"
      consumes:
      - "multipart/form-data"
      produces:
      - "application/xml"
      parameters:
      - name: "File"
        in: "formData"
        description: "The file to process."
        required: false
        type: "file"
      - name: "language"
        in: "query"
        description: "Recognition language of the document."
        required: false
        type: "string"
        default: "English"
      - name: "exportFormat"
        in: "query"
        description: "Specifies the export format."
        required: false
        type: "string"
        default: "pdfTextAndImages"
      responses:
        200:
          description: "Successful method call."
        450:
          description: "Incorrect parameters have been passed."
        550:
          description: "An internal program error occurred while processing the image."
        551:
          description: "An error occurred on the server side."

definitions: {}

Thanks

arcotek-ltd commented 6 years ago

I have cut down the definition to just:

{
  "swagger" : "2.0",
  "info" : {
    "description" : "OpenAPI for Abbyy's OCR SDK",
    "version" : "1.0.0",
    "title" : "AbbyyOCR",
    "contact" : {
      "email" : "blah@blah.com"
    }
  },
  "host" : "cloud.ocrsdk.com",
  "schemes" : [ "https" ],
  "basePath" : "/",
  "securityDefinitions" : {
    "basicAuth" : {
      "type" : "basic"
    }
  },
  "security" : [ {
    "basicAuth" : [ ]
  } ],
  "paths" : {
    "/getApplicationInfo" : {
      "get" : {
        "summary" : "Gets information about the account",
        "description" : "This method allows you to receive information about the application type, its current balance and expiration date. You may find it helpful for keeping the usage records.",
        "operationId": "GetApplicationInfo",
        "responses" : {
          "200" : {
            "description" : "Successful method call."
          },
          "403" : {
            "description" : "The call to this method is disabled in your application settings."
          }
        }
      }
    }
  }
}

I have to provide the credentials every time I test it and it's still generating the TypeError: Failed to fetch.

Thanks

arjun-g commented 6 years ago

Might be a CORS problem. Can you try to open in browser and see what error is shown in developer console.