Skip to content

Examples

The three pillars of our methodology: SPEC, EXAMPLES, IMPLEMENTATION.

Read the Spec

Browse Implementation Notes

API Reference

schema.go
//go:build jsonschema
// +build jsonschema
package basictypes
import (
"encoding/json"
jsonschema "github.com/tylergannon/go-gen-jsonschema"
)
// Schema method for SimpleInt.
// This stub will be replaced with a proper implementation during code generation.
// The method signature must match exactly: json.RawMessage
func (SimpleInt) Schema() json.RawMessage {
panic("not implemented") // This will be replaced by the generator
}
// Schema method for SimpleString.
func (SimpleString) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for SimpleFloat.
func (SimpleFloat) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for SimpleStruct.
func (SimpleStruct) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for TypeInNestedDecl.
func (TypeInNestedDecl) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for AnotherNestedType.
func (AnotherNestedType) Schema() json.RawMessage {
panic("not implemented")
}
// These marker variables register the types with the jsonschema generator.
// Each type that needs a schema must be registered here using NewJSONSchemaMethod.
var (
// Register SimpleInt for schema generation
_ = jsonschema.NewJSONSchemaMethod(SimpleInt.Schema)
// Register SimpleString for schema generation
_ = jsonschema.NewJSONSchemaMethod(SimpleString.Schema)
// Register SimpleFloat for schema generation
_ = jsonschema.NewJSONSchemaMethod(SimpleFloat.Schema)
// Register SimpleStruct for schema generation
_ = jsonschema.NewJSONSchemaMethod(SimpleStruct.Schema)
// Register TypeInNestedDecl for schema generation
_ = jsonschema.NewJSONSchemaMethod(TypeInNestedDecl.Schema)
// Register AnotherNestedType for schema generation
_ = jsonschema.NewJSONSchemaMethod(AnotherNestedType.Schema)
)
schema.go
//go:build jsonschema
// +build jsonschema
package enums
import (
"encoding/json"
jsonschema "github.com/tylergannon/go-gen-jsonschema"
)
// Schema method for Status.
// This stub will be replaced with a proper implementation during code generation.
func (Status) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for Priority.
func (Priority) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for Task.
func (Task) Schema() json.RawMessage {
panic("not implemented")
}
// Schema method for SliceOfStatus.
func (SliceOfStatus) Schema() json.RawMessage {
panic("not implemented")
}
// These marker variables register the types with the jsonschema generator.
var (
// Register Status for schema generation
_ = jsonschema.NewJSONSchemaMethod(Status.Schema)
// Register Priority for schema generation
_ = jsonschema.NewJSONSchemaMethod(Priority.Schema)
// Register Task for schema generation
_ = jsonschema.NewJSONSchemaMethod(Task.Schema)
// Register SliceOfStatus for schema generation
_ = jsonschema.NewJSONSchemaMethod(SliceOfStatus.Schema)
// Mark Status as an enum type
// This tells the generator to treat Status as an enum and include all defined
// constant values of this type in the schema.
_ = jsonschema.NewEnumType[Status]()
// Mark Priority as an enum type
_ = jsonschema.NewEnumType[Priority]()
)