Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Swagger #876

Merged
merged 19 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-&-publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
run: |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
export DOCKER_IMAGE_BASE="${BLOBBER_REGISTRY}:base"
export DOCKER_IMAGE_SWAGGER="${BLOBBER_REGISTRY}:swagger_test"
export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"
export DOCKER_IMAGE_BLOBBER="-t ${BLOBBER_REGISTRY}:${TAG} -t ${BLOBBER_REGISTRY}:${TAG}-${SHORT_SHA}"
docker buildx create --driver-opt network=host --use --buildkitd-flags '--allow-insecure-entitlement security.insecure' --use blobber_buildx
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ concurrency:
cancel-in-progress: true

on:
push:
push:
branches:
- master
- staging
Expand All @@ -15,7 +15,7 @@ on:
jobs:
linter:
name: Lints
runs-on: [self-hosted,docker-builds]
runs-on: [self-hosted,arc-runner]
steps:
- name: Setup go
uses: actions/setup-go@v3
Expand All @@ -29,6 +29,12 @@ jobs:
if: success()
run: make local

- name: Build Base
run: ./docker.local/bin/build.base.sh

- name: Check swagger generation
run: docker.local/bin/test.swagger.sh

- name: Golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -53,7 +59,7 @@ jobs:

- name: Run tests
run: |
cd $GITHUB_WORKSPACE/code/go/0chain.net/
cd $GITHUB_WORKSPACE/code/go/0chain.net/
CGO_ENABLED=1 go test -tags bn256 -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
Expand Down
1 change: 1 addition & 0 deletions code/go/0chain.net/blobber/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ func initHandlers(r *mux.Router) {
handler.StartTime = time.Now().UTC()
r.HandleFunc("/", handler.HomepageHandler)
handler.SetupHandlers(r)
handler.SetupSwagger()
common.SetAdminCredentials()
}
6 changes: 6 additions & 0 deletions code/go/0chain.net/blobbercore/blobberhttp/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/0chain/blobber/code/go/0chain.net/core/common"
)

// swagger:model UploadResult
type UploadResult struct {
Filename string `json:"filename"`
Size int64 `json:"size"`
Expand All @@ -21,6 +22,7 @@ type UploadResult struct {
UploadOffset int64 `json:"upload_offset"`
}

// swagger:model CommitResult
type CommitResult struct {
AllocationRoot string `json:"allocation_root"`
WriteMarker *writemarker.WriteMarker `json:"write_marker"`
Expand All @@ -30,11 +32,13 @@ type CommitResult struct {
//Result []*UploadResult `json:"result"`
}

// swagger:model ReferencePathResult
type ReferencePathResult struct {
*reference.ReferencePath
LatestWM *writemarker.WriteMarker `json:"latest_write_marker"`
}

// swagger:model RefResult
type RefResult struct {
TotalPages int `json:"total_pages"`
OffsetPath string `json:"offset_path,omitempty"` //used for pagination; index for path is created in database
Expand All @@ -43,6 +47,7 @@ type RefResult struct {
LatestWM *writemarker.WriteMarker `json:"latest_write_marker"`
}

// swagger:model RecentRefResult
type RecentRefResult struct {
Offset int `json:"offset"`
Refs []*reference.PaginatedRef `json:"refs"`
Expand All @@ -52,6 +57,7 @@ type ObjectPathResult struct {
LatestWM *writemarker.WriteMarker `json:"latest_write_marker"`
}

// swagger:model ListResult
type ListResult struct {
AllocationRoot string `json:"allocation_root"`
Meta map[string]interface{} `json:"meta_data"`
Expand Down
Loading