Kushal Bhalaik
Kushal Bhalaik

Reputation: 3384

"Unknown Error" while creating API spec in Swagger

Hi I'm creating a Sample API Spec using swagger as below :

I keep getting "Unknown Error on "Items:" line

swagger: "2.0"
info:
  version: "0.0.1"
  title: Todo API
# during dev, should point to your local machine
host: localhost:10010
# basePath prefixes all resource paths 
basePath: /
# 
schemes:
  # tip: remove http to make production-grade
  - http
  - https
# format of bodies a client can send (Content-Type)
consumes:
  - application/json
# format of the responses to the client (Accepts)
produces:
  - application/json
paths:
  /:
   get:
      description: "this endpoint returns list of todo events"
      operationId: "GetAllTodos"
      parameters:  []
      responses:
        200:
          description: "an array of all the present todos"
          schema:
              type: "array"
              items: 
                $ref: "#definitions/Todo"
      x-swagger-router-controller: "GetAllTodos"
  /swagger:
    x-swagger-pipe: swagger_raw
# complex objects have schema definitions
definitions:
 Todo:
  type: "object"
  properties: 
    todo_id:
      type: "integer"
      description: "id of the todo event"
    todo:
      type: "string"
      description: "The todo item"
    datecreated:
      type: "string"
      format: "date-time"
      description: "timestamp when the todo event was created"
    author:
      type: "string"
      description: "owner of the todo event"
    duedate:
      type: "string"
      format: "date-time"
      description: "time by when the todo event should be completed"
    completed:
      type: "boolean"
      description: "status of todo completion"

enter image description here

Upvotes: 0

Views: 1066

Answers (1)

Helen
Helen

Reputation: 97677

Change

$ref: "#definitions/Todo"

to

$ref: "#/definitions/Todo"

Note the / after #.

Also, you are using an old version of Swagger Editor (2.x), which is no longer maintained. Consider using the latest version at http://editor.swagger.io.

Upvotes: 2

Related Questions