Skip to content

Commit

Permalink
add an example swagger for test
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapacan committed Jul 30, 2024
1 parent c2b9718 commit cfebd98
Showing 1 changed file with 240 additions and 0 deletions.
240 changes: 240 additions & 0 deletions swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
openapi: 3.0.1
info:
title: Bookstore API
description: API for managing a bookstore
version: 1.0.0
servers:
- url: https://api.example.com/v1
description: Main (production) server
- url: https://staging-api.example.com/v1
description: Staging server
paths:
/books:
get:
summary: List all books
tags:
- Books
responses:
'200':
description: A list of books
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Book'
post:
summary: Create a new book
tags:
- Books
requestBody:
description: Book to add
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BookInput'
responses:
'201':
description: Book created
content:
application/json:
schema:
$ref: '#/components/schemas/Book'
/books/{bookId}:
get:
summary: Get a book by ID
tags:
- Books
parameters:
- name: bookId
in: path
required: true
schema:
type: string
responses:
'200':
description: A single book
content:
application/json:
schema:
$ref: '#/components/schemas/Book'
'404':
description: Book not found
put:
summary: Update a book by ID
tags:
- Books
parameters:
- name: bookId
in: path
required: true
schema:
type: string
requestBody:
description: Updated book
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BookInput'
responses:
'200':
description: Book updated
content:
application/json:
schema:
$ref: '#/components/schemas/Book'
'404':
description: Book not found
delete:
summary: Delete a book by ID
tags:
- Books
parameters:
- name: bookId
in: path
required: true
schema:
type: string
responses:
'204':
description: Book deleted
'404':
description: Book not found
/authors:
get:
summary: List all authors
tags:
- Authors
responses:
'200':
description: A list of authors
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Author'
post:
summary: Create a new author
tags:
- Authors
requestBody:
description: Author to add
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorInput'
responses:
'201':
description: Author created
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
/authors/{authorId}:
get:
summary: Get an author by ID
tags:
- Authors
parameters:
- name: authorId
in: path
required: true
schema:
type: string
responses:
'200':
description: A single author
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
'404':
description: Author not found
put:
summary: Update an author by ID
tags:
- Authors
parameters:
- name: authorId
in: path
required: true
schema:
type: string
requestBody:
description: Updated author
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorInput'
responses:
'200':
description: Author updated
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
'404':
description: Author not found
delete:
summary: Delete an author by ID
tags:
- Authors
parameters:
- name: authorId
in: path
required: true
schema:
type: string
responses:
'204':
description: Author deleted
'404':
description: Author not found
components:
schemas:
Book:
type: object
properties:
id:
type: string
title:
type: string
authorId:
type: string
publishedDate:
type: string
format: date
BookInput:
type: object
properties:
title:
type: string
authorId:
type: string
publishedDate:
type: string
format: date
Author:
type: object
properties:
id:
type: string
name:
type: string
birthDate:
type: string
format: date
AuthorInput:
type: object
properties:
name:
type: string
birthDate:
type: string
format: date

0 comments on commit cfebd98

Please sign in to comment.