Code Monkey home page Code Monkey logo

book-catalogue-spring-boot's Introduction

README

Steps and commands to run the application

This application is created using Spring Boot. The tomcat is embedded in the application set-up so no need to configure it separately. In order to run the application you must need to install few things as follows.

  • Java 1.8 or higher
  • Maven 3 or higher
  • Git Bash to run the curl commands.

Steps:

  • Download the project to a suitable directory.
  • Open the cmd on windows/mac OS command line with Admin Privilages.
  • Go to the path where you downloaded/extracted the project [eg.: C:\springBoot\project].
  • Build the project and run the tests by running mvn clean package
  • Run the project by running the command mvn spring-boot:run

API testing commands

Note: id=0 means it a new record. id is the unique key for each record.

  • To create a new book entry use following curl command. Change the details as per your requirement except the Id.
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" http://localhost:8080/book/createOrUpdate -d '{"author": { "firstName": "Chetan", "id": "0", "lastName": "Bhagat" }, "bookDesc": "Love Story", "bookName": "2 states", "id": "0"}'
  • To update an existing book entry use following curl command. Replace id attribute with your desired Id.
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" http://localhost:8080/book/createOrUpdate -d '{"author": { "firstName": "Chetan", "id": "1", "lastName": "Bhaget" }, "bookDesc": "Love Story", "bookName": "2 states", "id": "1"}'
  • To retriving a book use following curl command. Replace 1 with your desired Id to fetch other record.
curl -X GET --header 'Accept: application/json' 'http://localhost:8080/book/view/1'
  • The response error message when a book with certain Id id not found is as follows: {"errorCode":412,"message":"Book not found with Id: 599"}

  • The response error message when book Name is not provided: {"errorCode":412,"message":"Book name cannot be empty."}

  • For all successful cases the response will be:

{
  "author": {
    "firstName": "string",
    "id": 0,
    "lastName": "string"
  },
  "bookDesc": "string",
  "bookName": "string",
  "id": 0
}

Swagger UI for API testing

Additionally Swagger is also included in this project for API testing. You can hit the below link for Swagger UI and API testing from browser. http://localhost:8080/swagger-ui.html#!/

book-catalogue-spring-boot's People

Contributors

kparth01 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.