Getting Started
Install
Section titled “Install”go get github.com/tylergannon/go-gen-jsonschemaAdd a schema entrypoint
Section titled “Add a schema entrypoint”Create or edit a Go file in your package. Register a type and run codegen.
package example
//go:generate gen-jsonschema
import ("encoding/json"jsonschema "github.com/tylergannon/go-gen-jsonschema")
type User struct {ID int `json:"id"`Name string `json:"name"`}
// Stub method. The generator will replace this implementation.func (User) Schema() json.RawMessage { panic("not implemented") }
var (_ = jsonschema.NewJSONSchemaMethod(User.Schema))Generate
Section titled “Generate”go generate ./...This writes JSON Schema files to ./jsonschema and generates jsonschema_gen.go.
Next steps
Section titled “Next steps”- Read the Spec for enums, interfaces, and providers.
- Browse the Examples for working samples.
- See API Reference for the full exported API.