Skip to content

maxalves/starwars-planets-api

Repository files navigation

Build Status

Star Wars API

Restful API built with Java and Spring Framework.

Responses implement HAL specification (hal+json).

More information about HAL:

More information about HATEOAS:

Requirements

How to run

docker-compose up

Settings

  • This step IS NOT required!

You can change application port on docker-compose.yml file.

ports:
  - 8080:8080 <- CHANGE IT HERE

Application Settings are located on /src/main/resources and by default a development enviroment is loaded, change it as you wish

Endpoints

  1. Add Planet - Request

http://localhost:8080/v1/planets

    {
    	"name": "Tatooine",
    	"terrain": "temperate",
    	"climate": "ocean"
    }

Add Planet - Response

{
    "id": "{planetId}",
    "name": "Tatooine",
    "climate": "ocean",
    "terrain": "temperate",
    "_links": {
        "self": {
            "href": "http://localhost:8080/v1/planets/{planetId}"
        },
        "planets": {
            "href": "http://localhost:8080/v1/planets"
        }
    }
}
  1. Get Planet - Request

http://localhost:8080/v1/planets/{planetId}

Get Planet - Response

{
    "id": "{planetId}",
    "name": "Tatooine",
    "climate": "ocean",
    "terrain": "temperate",
    "_links": {
        "self": {
            "href": "http://localhost:8080/v1/planets/{planetId}"
        },
        "planets": {
            "href": "http://localhost:8080/v1/planets"
        }
    },
    "film_apparitions": 5
}
  1. Delete Planet - Request

http://localhost:8080/planets/{planetId}

Delete Planet - Response

{
    "id": "{planetId}",
    "name": "Tatooine",
    "climate": "ocean",
    "terrain": "temperate",
    "_links": {
        "planets": {
            "href": "http://localhost:8080/v1/planets"
        }
    }
}
  1. Get all planets - Request

Get all planets - Response

{
    "_embedded": {
        "items": [
            {
                "id": "{planetId}",
                "name": "Tatooine",
                "climate": "ocean",
                "terrain": "temperate",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/v1/planets/{planetId}"
                    },
                    "planets": {
                        "href": "http://localhost:8080/v1/planets"
                    }
                },
                "film_apparitions": 10
            }
        ]
    },
    "_links": {
        "self": {
            "href": "http://localhost:8080/v1/planets?page=1&size=1"
        },
        "next": {
            "href": "http://localhost:8080/v1/planets?page=2&size=1"
        }
    }
}

Tests

Tests run during CI build you can check the latest runs here https://dev.azure.com/max-personal/starwars-challenge/_build

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published