Created
March 28, 2025 11:16
-
-
Save Dhananjay-JSR/108f93fc3f203c8537ed2859e19d5b8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.0 | |
info: | |
title: Sample Book API | |
description: A simple API to manage books. | |
version: 1.0.0 | |
servers: | |
- url: https://api.example.com/v1 | |
description: Production server | |
paths: | |
/books: | |
get: | |
summary: Get a list of books | |
operationId: getBooks | |
tags: | |
- Books | |
responses: | |
'200': | |
description: A list of books | |
content: | |
application/json: | |
schema: | |
type: array | |
items: | |
$ref: '#/components/schemas/Book' | |
post: | |
summary: Add a new book | |
operationId: addBook | |
tags: | |
- Books | |
requestBody: | |
required: true | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Book' | |
responses: | |
'201': | |
description: Book created successfully | |
/books/{id}: | |
get: | |
summary: Get details of a book | |
operationId: getBookById | |
tags: | |
- Books | |
parameters: | |
- name: id | |
in: path | |
required: true | |
schema: | |
type: string | |
responses: | |
'200': | |
description: Details of the book | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Book' | |
'404': | |
description: Book not found | |
delete: | |
summary: Delete a book | |
operationId: deleteBook | |
tags: | |
- Books | |
parameters: | |
- name: id | |
in: path | |
required: true | |
schema: | |
type: string | |
responses: | |
'204': | |
description: Book deleted successfully | |
components: | |
schemas: | |
Book: | |
type: object | |
properties: | |
id: | |
type: string | |
example: "1" | |
title: | |
type: string | |
example: "The Great Gatsby" | |
author: | |
type: string | |
example: "F. Scott Fitzgerald" | |
publishedYear: | |
type: integer | |
example: 1925 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment