Skip to content

Commit 3022a40

Browse files
committed
feat: add Servers block to openapi spec
1 parent c941e23 commit 3022a40

File tree

3 files changed

+68
-10
lines changed

3 files changed

+68
-10
lines changed

buf-plugin-openapi/main.go

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ type OpenAPISpec struct {
2222
Paths map[string]PathItem `json:"paths"`
2323
Components *Components `json:"components,omitempty"`
2424
Tags []Tag `json:"tags,omitempty"`
25+
Servers []ServerInfo `json:"servers,omitempty"`
26+
}
27+
28+
type ServerInfo struct {
29+
URL string `json:"url"`
30+
Description string `json:"description,omitempty"`
2531
}
2632

2733
type OpenAPIInfo struct {
@@ -197,7 +203,7 @@ func main() {
197203

198204
// Initialize two OpenAPI specs - one for all paths and one for public paths
199205
allPathsSpec := createInitialSpec("EigenLayer API Specification", "Complete API specification for the EigenLayer protocol, including all services and types.")
200-
publicPathsSpec := createInitialSpec("EigenLayer Public API Specification", "Public API specification for the EigenLayer protocol, containing only publicly accessible endpoints.")
206+
publicPathsSpec := createInitialPublicSpec("EigenLayer Public API Specification", "Public API specification for the EigenLayer protocol, containing only publicly accessible endpoints.")
201207

202208
// Track unique tags for both specs
203209
seenTags := make(map[string]bool)
@@ -423,9 +429,9 @@ func createInitialSpec(title string, description string) OpenAPISpec {
423429
Version: "1.0.0",
424430
Description: description,
425431
Contact: &ContactInfo{
426-
Name: "EigenLayer Team",
427-
URL: "https://www.eigenlayer.xyz",
428-
432+
Name: "EigenLabs",
433+
URL: "https://sidecar-docs.eigenlayer.xyz",
434+
Email: "",
429435
},
430436
License: &LicenseInfo{
431437
Name: "MIT",
@@ -440,6 +446,46 @@ func createInitialSpec(title string, description string) OpenAPISpec {
440446
}
441447
}
442448

449+
// Helper function to create an initial OpenAPI spec
450+
func createInitialPublicSpec(title string, description string) OpenAPISpec {
451+
return OpenAPISpec{
452+
OpenAPI: "3.0.0",
453+
Info: OpenAPIInfo{
454+
Title: title,
455+
Version: "1.0.0",
456+
Description: description,
457+
Contact: &ContactInfo{
458+
Name: "EigenLabs",
459+
URL: "https://sidecar-rpc.eigenlayer.xyz",
460+
Email: "",
461+
},
462+
License: &LicenseInfo{
463+
Name: "MIT",
464+
URL: "https://opensource.org/licenses/MIT",
465+
},
466+
},
467+
Paths: make(map[string]PathItem),
468+
Components: &Components{
469+
Schemas: make(map[string]Schema),
470+
},
471+
Tags: []Tag{},
472+
Servers: []ServerInfo{
473+
{
474+
URL: "https://sidecar-rpc.eigenlayer.xyz/mainnet",
475+
Description: "Mainnet RPC server for the EigenLayer Sidecar",
476+
},
477+
{
478+
URL: "https://sidecar-rpc.eigenlayer.xyz/holesky",
479+
Description: "Holesky RPC server for the EigenLayer Sidecar",
480+
},
481+
{
482+
URL: "https://sidecar-rpc.eigenlayer.xyz/sepolia",
483+
Description: "Sepolia RPC server for the EigenLayer Sidecar",
484+
},
485+
},
486+
}
487+
}
488+
443489
func addMessageSchemas(message *protogen.Message, spec *OpenAPISpec, options *struct {
444490
EmitDefaults bool
445491
OmitEnumDefaultValue bool

gen/openapi/api.public.swagger.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"version": "1.0.0",
66
"description": "Public API specification for the EigenLayer protocol, containing only publicly accessible endpoints.",
77
"contact": {
8-
"name": "EigenLayer Team",
9-
"url": "https://www.eigenlayer.xyz",
10-
"email": "[email protected]"
8+
"name": "EigenLabs",
9+
"url": "https://sidecar-rpc.eigenlayer.xyz"
1110
},
1211
"license": {
1312
"name": "MIT",
@@ -2976,5 +2975,19 @@
29762975
"name": "slashing",
29772976
"description": "Operations from package slashing"
29782977
}
2978+
],
2979+
"servers": [
2980+
{
2981+
"url": "https://sidecar-rpc.eigenlayer.xyz/mainnet",
2982+
"description": "Mainnet RPC server for the EigenLayer Sidecar"
2983+
},
2984+
{
2985+
"url": "https://sidecar-rpc.eigenlayer.xyz/holesky",
2986+
"description": "Holesky RPC server for the EigenLayer Sidecar"
2987+
},
2988+
{
2989+
"url": "https://sidecar-rpc.eigenlayer.xyz/sepolia",
2990+
"description": "Sepolia RPC server for the EigenLayer Sidecar"
2991+
}
29792992
]
29802993
}

gen/openapi/api.swagger.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"version": "1.0.0",
66
"description": "Complete API specification for the EigenLayer protocol, including all services and types.",
77
"contact": {
8-
"name": "EigenLayer Team",
9-
"url": "https://www.eigenlayer.xyz",
10-
"email": "[email protected]"
8+
"name": "EigenLabs",
9+
"url": "https://sidecar-docs.eigenlayer.xyz"
1110
},
1211
"license": {
1312
"name": "MIT",

0 commit comments

Comments
 (0)