Skip to content

Commit

Permalink
Swagger refactor to isolate v1 & v2 APIs
Browse files Browse the repository at this point in the history
The mixed mode aspect of DataAPI is problematic for swagger and violates
many swagger assumptions. Swagger assumes 1 binary with 1 router that serves all API
versions, but with DataAPI v2 the v1 API are not available, and each
server mode instatiates its own router. To isolate v1/v2 API we define
separate swagger instances/packages. The real problematic piece is how
swagger dynamically finds handler endpoints. The only way to get it to
ignore v1 or v2 when build a specific version is to define handler
annotations in a subdir and generate swagger from that directory.
  • Loading branch information
pschork committed Dec 17, 2024
1 parent f8afd92 commit 94df1f0
Show file tree
Hide file tree
Showing 14 changed files with 2,409 additions and 1,598 deletions.
5 changes: 1 addition & 4 deletions disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/Layr-Labs/eigenda/disperser/common/blobstore"
blobstorev2 "github.com/Layr-Labs/eigenda/disperser/common/v2/blobstore"
"github.com/Layr-Labs/eigenda/disperser/dataapi"

"github.com/Layr-Labs/eigenda/disperser/dataapi/prometheus"
"github.com/Layr-Labs/eigenda/disperser/dataapi/subgraph"
"github.com/Layr-Labs/eigensdk-go/logging"
Expand All @@ -33,10 +34,6 @@ var (
gitDate string
)

// @title EigenDA Data Access API
// @description This is the EigenDA Data Access API server.
// @version 1
// @Schemes https http
func main() {
app := cli.NewApp()
app.Flags = flags.Flags
Expand Down
17 changes: 12 additions & 5 deletions disperser/dataapi/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
build:
build:
cd .. && go build -o ./bin/dataapi ./cmd/dataapi

test:
go test -v .

generate-swagger:
@echo " > Generating swagger..."
swag init -g ../cmd/dataapi/main.go --parseDependency
swag fmt
generate-swagger-v1:
@echo " > Generating v1 swagger..."
swag init -g swagger.go --parseDependency --parseInternal --output docs/v1 --instanceName V1 --packageName v1 --dir ./v1 --parseDepth 1
swag fmt --dir ./v1

generate-swagger-v2:
@echo " > Generating v2 swagger..."
swag init -g swagger.go --parseDependency --parseInternal --output docs/v2 --instanceName V2 --packageName v2 --dir ./v2 --parseDepth 1
swag fmt --dir ./v2

generate-swagger: generate-swagger-v1 generate-swagger-v2
Loading

0 comments on commit 94df1f0

Please sign in to comment.