Back to top

Dox Example

This api is implemented according to the JSON API spec.

Filter

If you want to filter your query, you can do so by setting the supported filter parameters in the following way:

  • ?author_id=24

Authors

Authors group

Authors

Get authors
GET/api/v1/authors

Example URI

GET /api/v1/authors
Request  returns a list of authors
HideShow

GET  /api/v1/authors

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": [
    {
      "id": "1",
      "type": "authors",
      "attributes": {
        "name": "Author_1"
      },
      "relationships": {
        "books": {
          "meta": {
            "included": false
          }
        }
      }
    }
  ]
}

Get an author
GET/api/v1/authors/{id}

Example URI

GET /api/v1/authors/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  returns an author
HideShow

GET  /api/v1/authors/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "1",
    "type": "authors",
    "attributes": {
      "name": "Author_2"
    },
    "relationships": {
      "books": {
        "data": []
      }
    }
  }
}
Request  does not find an author
HideShow

GET  /api/v1/authors/invalid_id

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  404
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": []
}

Create an author
POST/api/v1/authors

Example URI

POST /api/v1/authors
Request  creates a new Author
HideShow

POST  /api/v1/authors

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "author",
    "attributes": {
      "name": "Author_5"
    }
  }
}
Response  201
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "2",
    "type": "authors",
    "attributes": {
      "name": "Author_5"
    },
    "relationships": {
      "books": {
        "meta": {
          "included": false
        }
      }
    }
  }
}
Request  returns unprocessable entity
HideShow

POST  /api/v1/authors

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "author",
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Update an author
PUT/api/v1/authors/{id}

Example URI

PUT /api/v1/authors/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  updates the requested author
HideShow

PUT  /api/v1/authors/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "author",
    "id": 1,
    "attributes": {
      "name": "New Author"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "1",
    "type": "authors",
    "attributes": {
      "name": "New Author"
    },
    "relationships": {
      "books": {
        "meta": {
          "included": false
        }
      }
    }
  }
}
Request  returns unprocessable entity
HideShow

PUT  /api/v1/authors/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "author",
    "id": 1,
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Delete an author
DELETE/api/v1/authors/{id}

Example URI

DELETE /api/v1/authors/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  deletes the requested author
HideShow

DELETE  /api/v1/authors/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  204

Books

Book Collections

Get book collections
GET/api/v1/book_collections

Example URI

GET /api/v1/book_collections
Request  returns book collections
HideShow

GET  /api/v1/book_collections

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": [
    {
      "id": "1",
      "type": "book_collections",
      "attributes": {
        "name": "Book_collection_1"
      },
      "relationships": {
        "books": {
          "meta": {
            "included": false
          }
        }
      }
    }
  ]
}

Get a book collection
GET/api/v1/book_collections/{id}

Example URI

GET /api/v1/book_collections/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  returns a book collection
HideShow

GET  /api/v1/book_collections/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "1",
    "type": "book_collections",
    "attributes": {
      "name": "Book_collection_2"
    },
    "relationships": {
      "books": {
        "data": []
      }
    }
  }
}
Request  does not find a book collection
HideShow

GET  /api/v1/book_collections/invalid_id

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  404
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": []
}

Create a book collection
POST/api/v1/book_collections

Example URI

POST /api/v1/book_collections
Request  creates a new book collection
HideShow

POST  /api/v1/book_collections

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book_collection",
    "attributes": {
      "name": "Book_collection_5"
    }
  }
}
Response  201
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "2",
    "type": "book_collections",
    "attributes": {
      "name": "Book_collection_5"
    },
    "relationships": {
      "books": {
        "meta": {
          "included": false
        }
      }
    }
  }
}
Request  returns unprocessable entity
HideShow

POST  /api/v1/book_collections

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book_collection",
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Update a book collection
PUT/api/v1/book_collections/{id}

Example URI

PUT /api/v1/book_collections/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  updates the requested book collection
HideShow

PUT  /api/v1/book_collections/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book_collection",
    "id": 1,
    "attributes": {
      "name": "New Book Collection"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "1",
    "type": "book_collections",
    "attributes": {
      "name": "New Book Collection"
    },
    "relationships": {
      "books": {
        "meta": {
          "included": false
        }
      }
    }
  }
}
Request  returns unprocessable entity
HideShow

PUT  /api/v1/book_collections/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book_collection",
    "id": 1,
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Delete a book collection
DELETE/api/v1/book_collections/{id}

Example URI

DELETE /api/v1/book_collections/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  deletes the requested book collection
HideShow

DELETE  /api/v1/book_collections/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  204

Books

Supported filter params

  • author_id

Get books
GET/api/v1/books

Example URI

GET /api/v1/books
Request  returns books
HideShow

GET  /api/v1/books

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": [
    {
      "id": "1",
      "type": "books",
      "attributes": {
        "name": "Book_1"
      },
      "relationships": {
        "author": {
          "meta": {
            "included": false
          }
        },
        "book_collection": {
          "meta": {
            "included": false
          }
        }
      }
    }
  ]
}

Get a book
GET/api/v1/books/{id}

Example URI

GET /api/v1/books/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  returns a book
HideShow

GET  /api/v1/books/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "1",
    "type": "books",
    "attributes": {
      "name": "Book_2"
    },
    "relationships": {
      "author": {
        "data": {
          "type": "authors",
          "id": "1"
        }
      },
      "book_collection": {
        "data": {
          "type": "book_collections",
          "id": "1"
        }
      }
    }
  },
  "included": [
    {
      "id": "1",
      "type": "authors",
      "attributes": {
        "name": "Author_11"
      },
      "relationships": {
        "books": {
          "meta": {
            "included": false
          }
        }
      }
    },
    {
      "id": "1",
      "type": "book_collections",
      "attributes": {
        "name": "Book_collection_11"
      },
      "relationships": {
        "books": {
          "meta": {
            "included": false
          }
        }
      }
    }
  ]
}
Request  does not return a book
HideShow

GET  /api/v1/books/invalid_id

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  404
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": []
}

Create a book
POST/api/v1/books

Example URI

POST /api/v1/books
Request  creates a new book
HideShow

POST  /api/v1/books

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book",
    "attributes": {
      "name": "New Book",
      "author_id": 1
    }
  }
}
Response  201
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "2",
    "type": "books",
    "attributes": {
      "name": "New Book"
    },
    "relationships": {
      "author": {
        "meta": {
          "included": false
        }
      },
      "book_collection": {
        "meta": {
          "included": false
        }
      }
    }
  }
}
Request  returns unprocessable entity
HideShow

POST  /api/v1/books

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book",
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Author must exist",
      "source": {
        "parameter": "author",
        "pointer": "data/attributes/author"
      }
    },
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}
Request  doesn't create a new book
HideShow

POST  /api/v1/books

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book",
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Author must exist",
      "source": {
        "parameter": "author",
        "pointer": "data/attributes/author"
      }
    },
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Update a book
PUT/api/v1/books/{id}

Example URI

PUT /api/v1/books/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  updates the requested book
HideShow

PUT  /api/v1/books/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book",
    "id": 1,
    "attributes": {
      "name": "New Book"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "1",
    "type": "books",
    "attributes": {
      "name": "New Book"
    },
    "relationships": {
      "author": {
        "meta": {
          "included": false
        }
      },
      "book_collection": {
        "meta": {
          "included": false
        }
      }
    }
  }
}
Request  returns unprocessable entity
HideShow

PUT  /api/v1/books/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "book",
    "id": 1,
    "attributes": {
      "name": ""
    }
  }
}
Response  422
HideShow
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "title": "Unprocessable Entity",
      "detail": "Name can't be blank",
      "source": {
        "parameter": "name",
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Delete a book
DELETE/api/v1/books/{id}

Example URI

DELETE /api/v1/books/1
URI Parameters
HideShow
id
number (required) Example: 1
Request  deletes the requested book
HideShow

DELETE  /api/v1/books/1

Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response  204

Generated by aglio on 10 Jun 2017