Skip to content

Commit

Permalink
Merge pull request #411 from LerianStudio/develop
Browse files Browse the repository at this point in the history
Merge: develop to main
  • Loading branch information
MartinezAvellan authored Dec 19, 2024
2 parents 5640753 + 3641c82 commit e56f2e8
Show file tree
Hide file tree
Showing 33 changed files with 5,108 additions and 112 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/midaz-update-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ jobs:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cp midaz/components/audit/api/swagger.json LerianStudio.github.io/audit/
cp midaz/components/audit/api/openapi.yaml LerianStudio.github.io/audit/
cp midaz/components/ledger/api/swagger.json LerianStudio.github.io/ledger/
cp midaz/components/ledger/api/openapi.yaml LerianStudio.github.io/ledger/
cp midaz/components/transaction/api/swagger.json LerianStudio.github.io/transaction/
cp midaz/components/transaction/api/openapi.yaml LerianStudio.github.io/transaction/
- name: Commit and Push Swagger to Git Page
env:
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [1.36.0-beta.1](https://github.com/LerianStudio/midaz/compare/v1.35.0...v1.36.0-beta.1) (2024-12-19)


### Features

* add new oas 3.0 yaml ([d34059d](https://github.com/LerianStudio/midaz/commit/d34059d2e205f1a7c45ae55e2dc2bf56d6cba056))


### Bug Fixes

* remane to correct spelling name :bug: ([79da5bc](https://github.com/LerianStudio/midaz/commit/79da5bc9118edf793ae1c179d0dde8a04fe3e2e8))
* remove docker compose swag generate :bug: ([a65b347](https://github.com/LerianStudio/midaz/commit/a65b34773772b55ecfc19607570548f1182d1acd))

## [1.35.0](https://github.com/LerianStudio/midaz/compare/v1.34.0...v1.35.0) (2024-12-19)


Expand Down
2 changes: 1 addition & 1 deletion components/audit/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ENV_NAME=production

# APP
VERSION=v1.34.0
VERSION=v1.35.0
SERVER_PORT=3005
SERVER_ADDRESS=:${SERVER_PORT}

Expand Down
5 changes: 0 additions & 5 deletions components/audit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /app components/audit/cmd/app/main.go

# Add make, install swag and generate docs
RUN apk add --no-cache make \
&& go install github.com/swaggo/swag/cmd/swag@latest \
&& make -C components/audit generate-docs

FROM alpine:latest

COPY --from=builder /app /app
Expand Down
7 changes: 5 additions & 2 deletions components/audit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ info:
@echo " "
@echo "## App commands:"
@echo " "
@echo " COMMAND=\"generate-docs\" Generates Swagger API documentation using swag."
@echo " COMMAND=\"generate-docs\" Generates Swagger API documentation and an OpenAPI Specification."
@echo " "
@echo "## Docker commands:"
@echo " "
Expand Down Expand Up @@ -66,4 +66,7 @@ ps:
@docker-compose -f docker-compose.yml ps

generate-docs:
@swag init -g ../../../cmd/app/main.go -d ./internal/adapters/http -o ./api --parseDependency --parseInternal
@swag init -g ../../../cmd/app/main.go -d ./internal/adapters/http -o ./api --parseDependency --parseInternal
@docker run --rm -v ./:/audit --user $(shell id -u):$(shell id -g) openapitools/openapi-generator-cli:v5.1.1 generate -i ./audit/api/swagger.json -g openapi-yaml -o ./audit/api
@mv ./api/openapi/openapi.yaml ./api/openapi.yaml
@rm -rf ./api/README.md ./api/.openapi-generator* ./api/openapi
157 changes: 157 additions & 0 deletions components/audit/api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
openapi: 3.0.1
info:
contact:
name: Discord community
url: https://discord.gg/DnhqKwkGv3
description: This is a swagger documentation for the Midaz Audit API
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: Midaz Audit API
version: 1.0.0
servers:
- url: //localhost:3005/
paths:
/v1/organizations/{organization_id}/ledgers/{ledger_id}/audit/{audit_id}/audit-logs:
get:
description: Audit logs to check if any was tampered
parameters:
- description: Authorization Bearer Token
in: header
name: Authorization
required: true
schema:
type: string
- description: Request ID
in: header
name: Midaz-Id
schema:
type: string
- description: Organization ID
in: path
name: organization_id
required: true
schema:
type: string
- description: Ledger ID
in: path
name: ledger_id
required: true
schema:
type: string
- description: Audit ID
in: path
name: audit_id
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/HashValidationResponse'
description: OK
summary: Audit logs by reference ID
tags:
- Audit
/v1/organizations/{organization_id}/ledgers/{ledger_id}/audit/{audit_id}/read-logs:
get:
description: Get log values from Trillian by reference ID
parameters:
- description: Authorization Bearer Token
in: header
name: Authorization
required: true
schema:
type: string
- description: Request ID
in: header
name: Midaz-Id
schema:
type: string
- description: Organization ID
in: path
name: organization_id
required: true
schema:
type: string
- description: Ledger ID
in: path
name: ledger_id
required: true
schema:
type: string
- description: Audit ID
in: path
name: audit_id
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/LogsResponse'
description: OK
summary: "Get \tlogs by reference ID"
tags:
- Audit
components:
schemas:
HashValidationResponse:
description: HashValidationResponse show if any of the logs has been tampered
example:
auditId: auditId
isTampered: true
calculatedHash: calculatedHash
expectedHash: expectedHash
properties:
auditId:
type: string
calculatedHash:
type: string
expectedHash:
type: string
isTampered:
type: boolean
type: object
Leaf:
description: Leaf stores each audit log
example:
body:
- 0
- 0
leaf_id: leaf_id
properties:
body:
items:
type: integer
type: array
leaf_id:
type: string
type: object
LogsResponse:
description: LogsResponse is the response with audit log values
example:
leaves:
- body:
- 0
- 0
leaf_id: leaf_id
- body:
- 0
- 0
leaf_id: leaf_id
tree_id: 6
properties:
leaves:
items:
$ref: '#/components/schemas/Leaf'
type: array
tree_id:
type: integer
type: object
x-original-swagger-version: "2.0"
2 changes: 1 addition & 1 deletion components/ledger/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ENV_NAME=production

# APP
VERSION=v1.34.0
VERSION=v1.35.0
SERVER_PORT=3000
SERVER_ADDRESS=:${SERVER_PORT}

Expand Down
6 changes: 0 additions & 6 deletions components/ledger/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /app components/ledger/cmd/app/main.go

# Add make, install swag and generate docs
RUN apk add --no-cache make \
&& go install github.com/swaggo/swag/cmd/swag@latest \
&& make -C components/ledger generate-docs


FROM alpine:latest

COPY --from=builder /app /app
Expand Down
5 changes: 4 additions & 1 deletion components/ledger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ info:
@echo " COMMAND=\"test\" Runs all Go tests in the project with verbose output."
@echo " COMMAND=\"cover-html\" Generates an HTML report from Go test coverage data."
@echo " COMMAND=\"tidy\" Cleans and updates Go dependencies in the go.mod file."
@echo " COMMAND=\"generate-docs\" Generates Swagger API documentation using swag."
@echo " COMMAND=\"generate-docs\" Generates Swagger API documentation and an OpenAPI Specification."
@echo " "
@echo "## Docker commands:"
@echo " "
Expand Down Expand Up @@ -59,6 +59,9 @@ tidy:

generate-docs:
@swag init -g ../../../cmd/app/main.go -d ./internal/adapters/http -o ./api --parseDependency --parseInternal
@docker run --rm -v ./:/ledger --user $(shell id -u):$(shell id -g) openapitools/openapi-generator-cli:v5.1.1 generate -i ./ledger/api/swagger.json -g openapi-yaml -o ./ledger/api
@mv ./api/openapi/openapi.yaml ./api/openapi.yaml
@rm -rf ./api/README.md ./api/.openapi-generator* ./api/openapi

# Docker Compose Commands
build:
Expand Down
12 changes: 0 additions & 12 deletions components/ledger/api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ const docTemplate = `{
},
{
"type": "string",
"example": "2021-01-01",
"description": "Start Date",
"name": "start_date",
"in": "query"
},
{
"type": "string",
"example": "2021-01-01",
"description": "End Date",
"name": "end_date",
"in": "query"
Expand Down Expand Up @@ -350,14 +348,12 @@ const docTemplate = `{
},
{
"type": "string",
"example": "2021-01-01",
"description": "Start Date",
"name": "start_date",
"in": "query"
},
{
"type": "string",
"example": "2021-01-01",
"description": "End Date",
"name": "end_date",
"in": "query"
Expand Down Expand Up @@ -665,14 +661,12 @@ const docTemplate = `{
},
{
"type": "string",
"example": "2021-01-01",
"description": "Start Date",
"name": "start_date",
"in": "query"
},
{
"type": "string",
"example": "2021-01-01",
"description": "End Date",
"name": "end_date",
"in": "query"
Expand Down Expand Up @@ -1008,14 +1002,12 @@ const docTemplate = `{
},
{
"type": "string",
"example": "2021-01-01",
"description": "Start Date",
"name": "start_date",
"in": "query"
},
{
"type": "string",
"example": "2021-01-01",
"description": "End Date",
"name": "end_date",
"in": "query"
Expand Down Expand Up @@ -1351,14 +1343,12 @@ const docTemplate = `{
},
{
"type": "string",
"example": "2021-01-01",
"description": "Start Date",
"name": "start_date",
"in": "query"
},
{
"type": "string",
"example": "2021-01-01",
"description": "End Date",
"name": "end_date",
"in": "query"
Expand Down Expand Up @@ -2028,14 +2018,12 @@ const docTemplate = `{
},
{
"type": "string",
"example": "2021-01-01",
"description": "Start Date",
"name": "start_date",
"in": "query"
},
{
"type": "string",
"example": "2021-01-01",
"description": "End Date",
"name": "end_date",
"in": "query"
Expand Down
Loading

0 comments on commit e56f2e8

Please sign in to comment.