From 0e8bc6dd5bfed74dc0908223680be52d8b7043d8 Mon Sep 17 00:00:00 2001 From: Gbadebo Bello Date: Tue, 24 Mar 2026 12:47:24 +0100 Subject: [PATCH 1/2] commit message --- .postman/resources.yaml | 9 ++++ .../Book-API/.resources/definition.yaml | 8 ++++ .../Book-API/Books/.resources/definition.yaml | 4 ++ .../Book-API/Books/Create Book.request.yaml | 42 ++++++++++++++++++ .../Book-API/Books/Delete Book.request.yaml | 26 +++++++++++ .../Book-API/Books/Get Book.request.yaml | 29 +++++++++++++ .../Book-API/Books/List Books.request.yaml | 22 ++++++++++ .../Book-API/Books/Update Book.request.yaml | 43 +++++++++++++++++++ .../Health & Info/.resources/definition.yaml | 4 ++ .../Health & Info/Health Check.request.yaml | 23 ++++++++++ .../Book-API/Health & Info/Root.request.yaml | 22 ++++++++++ postman/globals/workspace.globals.yaml | 2 + 12 files changed, 234 insertions(+) create mode 100644 .postman/resources.yaml create mode 100644 postman/collections/Book-API/.resources/definition.yaml create mode 100644 postman/collections/Book-API/Books/.resources/definition.yaml create mode 100644 postman/collections/Book-API/Books/Create Book.request.yaml create mode 100644 postman/collections/Book-API/Books/Delete Book.request.yaml create mode 100644 postman/collections/Book-API/Books/Get Book.request.yaml create mode 100644 postman/collections/Book-API/Books/List Books.request.yaml create mode 100644 postman/collections/Book-API/Books/Update Book.request.yaml create mode 100644 postman/collections/Book-API/Health & Info/.resources/definition.yaml create mode 100644 postman/collections/Book-API/Health & Info/Health Check.request.yaml create mode 100644 postman/collections/Book-API/Health & Info/Root.request.yaml create mode 100644 postman/globals/workspace.globals.yaml diff --git a/.postman/resources.yaml b/.postman/resources.yaml new file mode 100644 index 0000000..913a4e2 --- /dev/null +++ b/.postman/resources.yaml @@ -0,0 +1,9 @@ +# Use this workspace to collaborate +workspace: + id: 9228adbf-de74-4b01-afc0-3a536f8c5d91 + +# All resources in the `postman/` folder are automatically registered in Local View. +# Point to additional files outside the `postman/` folder to register them individually. Example: +#localResources: +# collections: +# - ../tests/E2E Test Collection/ diff --git a/postman/collections/Book-API/.resources/definition.yaml b/postman/collections/Book-API/.resources/definition.yaml new file mode 100644 index 0000000..6083815 --- /dev/null +++ b/postman/collections/Book-API/.resources/definition.yaml @@ -0,0 +1,8 @@ +$kind: collection +name: Book API +description: A REST API for managing books. This collection provides endpoints + for creating, reading, updating, and deleting books, as well as health check + and API info endpoints. +variables: + baseUrl: http://localhost:3000 + bookId: "" diff --git a/postman/collections/Book-API/Books/.resources/definition.yaml b/postman/collections/Book-API/Books/.resources/definition.yaml new file mode 100644 index 0000000..ff4abb6 --- /dev/null +++ b/postman/collections/Book-API/Books/.resources/definition.yaml @@ -0,0 +1,4 @@ +$kind: collection +name: Books +description: CRUD operations for managing books +order: 2000 diff --git a/postman/collections/Book-API/Books/Create Book.request.yaml b/postman/collections/Book-API/Books/Create Book.request.yaml new file mode 100644 index 0000000..676bcb7 --- /dev/null +++ b/postman/collections/Book-API/Books/Create Book.request.yaml @@ -0,0 +1,42 @@ +$kind: http-request +name: Create Book +method: POST +url: '{{baseUrl}}/api/v1/books' +order: 3000 +headers: + - key: Content-Type + value: application/json +body: + type: json + content: |- + { + "title": "The Great Gatsby", + "author": "F. Scott Fitzgerald", + "year": 1925, + "publisher": "Charles Scribner's Sons" + } +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 201", function () { + pm.response.to.have.status(201); + }); + + pm.test("Response has 'book' with 'id'", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("book"); + pm.expect(jsonData.book).to.have.property("id"); + }); + + pm.test("Book title matches request", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData.book.title).to.eql("The Great Gatsby"); + }); + + pm.test("Store bookId in collection variables", function () { + const jsonData = pm.response.json(); + if (jsonData.book && jsonData.book.id) { + pm.collectionVariables.set("bookId", jsonData.book.id); + } + }); \ No newline at end of file diff --git a/postman/collections/Book-API/Books/Delete Book.request.yaml b/postman/collections/Book-API/Books/Delete Book.request.yaml new file mode 100644 index 0000000..0e0571a --- /dev/null +++ b/postman/collections/Book-API/Books/Delete Book.request.yaml @@ -0,0 +1,26 @@ +$kind: http-request +name: Delete Book +method: DELETE +url: '{{baseUrl}}/api/v1/books/:id' +order: 5000 +pathVariables: + - key: id + value: '1' + description: The unique identifier of the book to delete +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 200", function () { + pm.response.to.have.status(200); + }); + + pm.test("Response has 'message' equal to 'Book deleted'", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData.message).to.eql("Book deleted"); + }); + + pm.test("Response has 'id' property", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("id"); + }); \ No newline at end of file diff --git a/postman/collections/Book-API/Books/Get Book.request.yaml b/postman/collections/Book-API/Books/Get Book.request.yaml new file mode 100644 index 0000000..995f664 --- /dev/null +++ b/postman/collections/Book-API/Books/Get Book.request.yaml @@ -0,0 +1,29 @@ +$kind: http-request +name: Get Book +method: GET +url: '{{baseUrl}}/api/v1/books/:id' +order: 2000 +pathVariables: + - key: id + value: '1' + description: The unique identifier of the book +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 200", function () { + pm.response.to.have.status(200); + }); + + pm.test("Response has 'book' object", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("book"); + pm.expect(jsonData.book).to.be.an("object"); + }); + + pm.test("Book has id, title, author fields", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData.book).to.have.property("id"); + pm.expect(jsonData.book).to.have.property("title"); + pm.expect(jsonData.book).to.have.property("author"); + }); \ No newline at end of file diff --git a/postman/collections/Book-API/Books/List Books.request.yaml b/postman/collections/Book-API/Books/List Books.request.yaml new file mode 100644 index 0000000..1673125 --- /dev/null +++ b/postman/collections/Book-API/Books/List Books.request.yaml @@ -0,0 +1,22 @@ +$kind: http-request +name: List Books +method: GET +url: '{{baseUrl}}/api/v1/books' +order: 1000 +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 200", function () { + pm.response.to.have.status(200); + }); + + pm.test("Response has 'books' array", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("books"); + pm.expect(jsonData.books).to.be.an("array"); + }); + + pm.test("Response time under 500ms", function () { + pm.expect(pm.response.responseTime).to.be.below(500); + }); \ No newline at end of file diff --git a/postman/collections/Book-API/Books/Update Book.request.yaml b/postman/collections/Book-API/Books/Update Book.request.yaml new file mode 100644 index 0000000..925c1d3 --- /dev/null +++ b/postman/collections/Book-API/Books/Update Book.request.yaml @@ -0,0 +1,43 @@ +$kind: http-request +name: Update Book +method: PUT +url: '{{baseUrl}}/api/v1/books/:id' +order: 4000 +headers: + - key: Content-Type + value: application/json +pathVariables: + - key: id + value: '1' + description: The unique identifier of the book to update +body: + type: json + content: |- + { + "title": "Updated Title", + "author": "Updated Author", + "year": 2024, + "publisher": "Updated Publisher" + } +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 200", function () { + pm.response.to.have.status(200); + }); + + pm.test("Response has 'book' object", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("book"); + pm.expect(jsonData.book).to.be.an("object"); + }); + + pm.test("Book has all required fields", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData.book).to.have.property("id"); + pm.expect(jsonData.book).to.have.property("title"); + pm.expect(jsonData.book).to.have.property("author"); + pm.expect(jsonData.book).to.have.property("year"); + pm.expect(jsonData.book).to.have.property("publisher"); + }); \ No newline at end of file diff --git a/postman/collections/Book-API/Health & Info/.resources/definition.yaml b/postman/collections/Book-API/Health & Info/.resources/definition.yaml new file mode 100644 index 0000000..85a01e2 --- /dev/null +++ b/postman/collections/Book-API/Health & Info/.resources/definition.yaml @@ -0,0 +1,4 @@ +$kind: collection +name: Health & Info +description: Health check and API information endpoints +order: 1000 diff --git a/postman/collections/Book-API/Health & Info/Health Check.request.yaml b/postman/collections/Book-API/Health & Info/Health Check.request.yaml new file mode 100644 index 0000000..613a9fb --- /dev/null +++ b/postman/collections/Book-API/Health & Info/Health Check.request.yaml @@ -0,0 +1,23 @@ +$kind: http-request +name: Health Check +method: GET +url: '{{baseUrl}}/health' +order: 2000 +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 200", function () { + pm.response.to.have.status(200); + }); + + pm.test("Status is 'ok'", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData.status).to.eql("ok"); + }); + + pm.test("Response has valid timestamp", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("timestamp"); + pm.expect(new Date(jsonData.timestamp).getTime()).to.be.a("number"); + }); \ No newline at end of file diff --git a/postman/collections/Book-API/Health & Info/Root.request.yaml b/postman/collections/Book-API/Health & Info/Root.request.yaml new file mode 100644 index 0000000..209f8cd --- /dev/null +++ b/postman/collections/Book-API/Health & Info/Root.request.yaml @@ -0,0 +1,22 @@ +$kind: http-request +name: Root +method: GET +url: '{{baseUrl}}/' +order: 1000 +scripts: + - type: afterResponse + language: text/javascript + code: |- + pm.test("Status code is 200", function () { + pm.response.to.have.status(200); + }); + + pm.test("Response has 'message' equal to 'Book API'", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData.message).to.eql("Book API"); + }); + + pm.test("Response has 'docs' property", function () { + const jsonData = pm.response.json(); + pm.expect(jsonData).to.have.property("docs"); + }); \ No newline at end of file diff --git a/postman/globals/workspace.globals.yaml b/postman/globals/workspace.globals.yaml new file mode 100644 index 0000000..e96c6d6 --- /dev/null +++ b/postman/globals/workspace.globals.yaml @@ -0,0 +1,2 @@ +name: Globals +values: [] From 965683b2375eba862bc677d027674df966e639e5 Mon Sep 17 00:00:00 2001 From: Bello Gbadebo Date: Wed, 25 Mar 2026 16:48:00 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e62bf78..c4fe29c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ curl -X PUT http://localhost:3000/api/v1/books/1 \ -d '{"title":"Dune","author":"Frank Herbert","year":1965}' ``` -**Delete book** +**Delete a book** ```bash curl -X DELETE http://localhost:3000/api/v1/books/1 ```