Sign inSign up

tdekarz/spring-pet-project

By tdekarz

•Updated over 8 years ago

Personal pet project for a spring-based microservice

Image
0

835

tdekarz/spring-pet-project repository overview

Build Status codecov Codacy Badge License Docker Stars Docker Pulls

⁠Spring Pet Project

Personal pet project for a spring-based microservice

⁠Releases

This project is available on dockerhub:

docker run -p 8080:8080/tcp tdekarz/spring-pet-project:latest
⁠Usage:

GET ALL

curl -i -H "Accept: application/json"  -X GET /user

Response - 200

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/user"
    },
    "start": {
      "href": "http://localhost:8080/user/59b1a63fee411e372464dd7a"
    }
  },
  "total": 3,
  "content": [
    {
      "_links": {
        "self": {
          "href": "http://localhost:8080/user/59b1a63fee411e372464dd7a"
        }
      },
      "content": {
        "id": "59b1a63fee411e372464dd7a",
        "firstName": "AWS1",
        "lastName": "AWS"
      }
    },
    {
      "_links": {
        "self": {
          "href": "http://localhost:8080/user/59b1a63fee411e372464dd7b"
        }
      },
      "content": {
        "id": "59b1a63fee411e372464dd7b",
        "firstName": "AWS4",
        "lastName": "AWS2"
      }
    },
    {
      "_links": {
        "self": {
          "href": "http://localhost:8080/user/59b1a63fee411e372464dd7c"
        }
      },
      "content": {
        "id": "59b1a63fee411e372464dd7c",
        "firstName": "Lara",
        "lastName": "Lavendel"
      }
    }
  ]
}

GET ONE

curl -i -H "Accept: application/json"  -X GET /user/{userId}

Response - 200

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58fe"
    },
    "start": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58fd"
    },
    "prev": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58fd"
    },
    "next": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58ff"
    }
  },
  "content": {
    "id": "599f2e6170f9864ae00c58fe",
    "firstName": "AWS4",
    "secondName": null,
    "lastName": "AWS2",
    "age": 30,
    "vip": false,
    "login": {
      "mail": "[email protected]",
      "password": "somePassword"
    },
    "bio": null
  }
}

CREATE

curl -i -H "Content-Type: application/json" -X POST /user

Body

{
  "firstName": "AWS",
  "secondName": "Joachim",
  "lastName": "AWS",
  "age": 30,
  "vip": false,
  "login": {
      "mail": "[email protected]",
      "password": "somePassword"
  },
  "bio": "some text"
}

Response 201 Location: http://localhost:8080/user/599f2ec570f9864ae00c5900

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/user/599f2ec570f9864ae00c5900"
    },
    "start": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58fd"
    },
    "prev": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58ff"
    }
  },
  "content": {
    "id": "599f2ec570f9864ae00c5900",
    "firstName": "AWS1",
    "secondName": null,
    "lastName": "AWS",
    "age": 30,
    "vip": false,
    "login": {
      "mail": "[email protected]",
      "password": "somePassword"
    },
    "bio": null
  }
}

UPDATE

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X PUT /user/{userId}

Body

{
     "id": "599f2ec570f9864ae00c5900",
    "firstName": "AWS10",
    "secondName": null,
    "lastName": "AWS",
    "age": 30,
    "vip": false,
    "login": {
        "mail": "[email protected]",
        "password": "somePassword"
    },
    "bio": null
}

Response 200

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/user/599f2ec570f9864ae00c5900"
    },
    "start": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58fd"
    },
    "prev": {
      "href": "http://localhost:8080/user/599f2e6170f9864ae00c58ff"
    }
  },
  "content": {
    "id": "599f2ec570f9864ae00c5900",
    "firstName": "AWS10",
    "secondName": null,
    "lastName": "AWS",
    "age": 30,
    "vip": false,
    "login": {
      "mail": "[email protected]",
      "password": "somePassword"
    },
    "bio": null
  }
}

DELETE

curl -i  -X DELETE /user/{userId}

Response - 204

⁠Errors

If possible the following error object will returned on any proccessing error

Response - 400

{
  "errors": [
    {
      "attribute": "user",
      "errorMessage": "Das Password ist unsicher"
    },
    {
      "attribute": "user",
      "errorMessage": "Alter muss mindestens 18 sein"
    },
    {
      "attribute": "user",
      "errorMessage": "Das Pssword ist verpflichtend"
    }
  ],
  "user": {
    "firstName": "NEU",
    "secondName": "Joachim",
    "lastName": "AWS",
    "age": 30,
    "vip": false,
    "login": {
    "mail": "[email protected]",
    "password": "somePassword"
    },
    "bio": "some text"
  }
}

Tag summary

Content type

Image

Digest

Size

137.5 MB

Last updated

over 8 years ago

docker pull tdekarz/spring-pet-project