From cfebd988e47f8d77cb6996c5bc90a3fd02392651 Mon Sep 17 00:00:00 2001 From: tchapacan Date: Tue, 30 Jul 2024 10:24:12 +0200 Subject: [PATCH] add an example swagger for test --- swagger.yaml | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 swagger.yaml diff --git a/swagger.yaml b/swagger.yaml new file mode 100644 index 0000000..7a61de0 --- /dev/null +++ b/swagger.yaml @@ -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 +