diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..482a6c1 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,58 @@ +name: Pull Request Checks + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Build + id: go-build + run: | + wget https://github.com/swaggo/swag/releases/download/v1.7.1/swag_linux_amd64.tar.gz -O - | tar -xz -C /tmp && cp /tmp/swag_linux_amd64/swag /usr/local/bin + make build + + golangci-lint: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v2 + with: + go_version: 1.16 + filter_mode: nofilter + +# - name: Set up Go +# uses: actions/setup-go@v2 +# with: +# go-version: 1.16 +# +# - name: Build +# id: generate-swaager-docs +# run: | +# wget https://github.com/swaggo/swag/releases/download/v1.7.1/swag_linux_amd64.tar.gz -O - | tar -xz -C /tmp && cp /tmp/swag_linux_amd64/swag /usr/local/bin +# make build \ No newline at end of file diff --git a/docs/openapi.json b/docs/openapi.json new file mode 100644 index 0000000..252b49a --- /dev/null +++ b/docs/openapi.json @@ -0,0 +1,217 @@ +{ + "openapi": "3.0.1", + "info": { + "contact": {}, + "title": "mobile wallet", + "version": "1.0.0" + }, + "servers": [ + { + "url": "/" + } + ], + "paths": { + "/books": { + "get": { + "tags": [ + "books" + ], + "summary": "Get books", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/model.BookResponseDTO" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "books" + ], + "summary": "Create Book", + "requestBody": { + "description": "body", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/model.BookRequestDTO" + } + } + }, + "required": false + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/model.BookResponseDTO" + } + } + } + } + }, + "x-codegen-request-body-name": "body" + } + }, + "/books/{id}": { + "get": { + "tags": [ + "books" + ], + "summary": "Get the book by id", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/model.BookResponseDTO" + } + } + } + } + } + }, + "put": { + "tags": [ + "books" + ], + "summary": "Update the book information", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "body", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/model.BookRequestDTO" + } + } + }, + "required": false + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/model.BookResponseDTO" + } + } + } + } + }, + "x-codegen-request-body-name": "body" + }, + "delete": { + "tags": [ + "books" + ], + "summary": "Delete the book", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": {} + } + } + } + } + }, + "components": { + "schemas": { + "model.BookRequestDTO": { + "required": [ + "author", + "publisher", + "title" + ], + "type": "object", + "properties": { + "author": { + "type": "string", + "description": "book author", + "example": "David Wiesner" + }, + "publisher": { + "type": "string", + "description": "book publisher", + "example": "Clarion Books" + }, + "title": { + "type": "string", + "description": "book title", + "example": "The Three Pigs" + } + } + }, + "model.BookResponseDTO": { + "type": "object", + "properties": { + "author": { + "type": "string", + "description": "book author", + "example": "David Wiesner" + }, + "id": { + "type": "integer", + "description": "book id", + "example": 1234 + }, + "publisher": { + "type": "string", + "description": "book publisher", + "example": "Clarion Books" + }, + "title": { + "type": "string", + "description": "book title", + "example": "The Three Pigs" + } + } + } + } + } +}