Skip to content

Instantly share code, notes, and snippets.

@pcfreak30
Created November 2, 2024 00:16
Show Gist options
  • Save pcfreak30/c1a6c73450c16f9508c1024b2f5b25f2 to your computer and use it in GitHub Desktop.
Save pcfreak30/c1a6c73450c16f9508c1024b2f5b25f2 to your computer and use it in GitHub Desktop.
akash_dynamic_sdl_schema
package main
import (
"encoding/json"
"fmt"
manifest "github.com/akash-network/akash-api/go/manifest/v2beta2"
"github.com/invopop/jsonschema"
"os"
"reflect"
)
func main() {
// Create a new reflector
r := &jsonschema.Reflector{
RequiredFromJSONSchemaTags: true,
AllowAdditionalProperties: true,
DoNotReference: true,
ExpandedStruct: true,
}
// Generate the schema from the Manifest type
schema := r.ReflectFromType(reflect.TypeOf(manifest.Manifest{}))
// Add schema metadata
schema.Title = "Akash Deployment Manifest"
schema.Description = "JSON Schema for Akash Network deployment manifest"
schema.Version = "v2beta2"
// Convert to JSON with pretty printing
schemaJSON, err := json.MarshalIndent(schema, "", " ")
if err != nil {
fmt.Printf("Error marshaling schema: %v\n", err)
os.Exit(1)
}
// Print the schema
fmt.Println(string(schemaJSON))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment