This document provides a summary of the Movies RESTful WebAPI, which was created as a proof-of-concept application to store data in an in-memory database and return it back over HTTP in JSON format.
The database is seeded with a set of test data and is re-created on each launch of the application. A possible future enhancement would be to make the seeding optional via launch parameters.
The following frameworks and packages were used to implement the application:
- ASP.NET Core 2.1.1
- Entity Framework Core 2.1.1 w/ SQLite
- Newtonsoft.Json
- NUnit and FluentAssertions (unit tests)
- Log4Net (debugging)
- Swashbuckle (Swagger generator)
Full, interactive API documentation can be accessed from within the application via the route: /swagger
Gets all of the movies in the database
Possible response codes:
- 200: Returns the list of movies
Example: https://localhost:44366/api/movies
Response body:
[
{
"$id":"73",
"movieId":1,
"title":"They Live",
"description":"Science fiction thriller, directed by John Carpenter",
"movieActors":[
{
"$id":"74",
"movieId":1,
"movie":{
"$ref":"73"
},
"actorId":1,
"actor":{
"$id":"75",
"actorId":1,
"firstName":"'Rowdy' Roddy",
"surname":"Piper",
"movieActors":[
{
"$ref":"74"
}
]
}
},
{
"$id":"76",
"movieId":1,
"movie":{
"$ref":"73"
},
"actorId":2,
"actor":{
"$id":"77",
"actorId":2,
"firstName":"Keith",
"surname":"David",
"movieActors":[
{
"$ref":"76"
}
]
}
}
]
},
{
"$id":"78",
"movieId":2,
"title":"Taxi Driver",
"description":"Martin Scorsese, neo-noir classic",
"movieActors":[
{
"$id":"79",
"movieId":2,
"movie":{
"$ref":"78"
},
"actorId":3,
"actor":{
"$id":"80",
"actorId":3,
"firstName":"Robert",
"surname":"De Niro",
"movieActors":[
{
"$ref":"79"
}
]
}
}
]
}
]
Get a specific movie by ID
Possible response codes:
- 200: Returns the movie requested
- 404: If a single movie with the requested ID cannot be found
Example: https://localhost:44366/api/movies/3
Response body:
{
"$id":"29",
"movieId":3,
"title":"Cape Fear",
"description":"Creepy boat scene, parodied by The Simpsons",
"movieActors":[
{
"$id":"30",
"movieId":3,
"movie":{
"$ref":"29"
},
"actorId":3,
"actor":{
"$id":"31",
"actorId":3,
"firstName":"Robert",
"surname":"De Niro",
"movieActors":[
{
"$ref":"30"
}
]
}
}
]
}
Creates a new movie
Possible response codes:
- 201: The movie was created successfully
- 400: If a null model was passed in
- 404: If a referenced actor ID cannot be found
Sample request:
POST /api/movies
{
"Title":"Jurassic Park",
"Description":"Dinosaurs",
"MovieActors":[
{
"ActorId":5
}
]
}
Update an existing movie's title or description
Possible response codes:
- 200: The movie was updated successfully
- 400: If a null model was passed in
- 404: If a single movie with the requested ID cannot be found
Sample request:
PUT /api/movies/1
{
"Description":"This movie recently won an oscar"
}
Delete a specified movie
Possible response codes:
- 200: The movie was updated successfully
- 404: If a single movie with the requested ID cannot be found