Documentation
¶
Index ¶
- Variables
- func RenderSchema(schema *types.Schema, r Renderer) []string
- func RenderType(t *types.TypeElement, r Renderer) []string
- type JSONRenderer
- func (r *JSONRenderer) DeReference() bool
- func (r *JSONRenderer) Indent() int
- func (r *JSONRenderer) Path(t *types.TypeElement) []string
- func (r *JSONRenderer) Post(t *types.TypeElement) []string
- func (r *JSONRenderer) Pre(t *types.TypeElement) []string
- func (r *JSONRenderer) Prefix() string
- func (r *JSONRenderer) ProcessResult(result *types.Schema) ([]string, error)
- func (r *JSONRenderer) SetIndent(value int)
- type OpenAPIRenderer
- func (r *OpenAPIRenderer) DeReference() bool
- func (r *OpenAPIRenderer) Indent() int
- func (r *OpenAPIRenderer) Path(t *types.TypeElement) []string
- func (r *OpenAPIRenderer) Post(t *types.TypeElement) []string
- func (r *OpenAPIRenderer) Pre(t *types.TypeElement) []string
- func (r *OpenAPIRenderer) Prefix() string
- func (r *OpenAPIRenderer) ProcessResult(result *types.Schema) ([]string, error)
- func (r *OpenAPIRenderer) SetIndent(value int)
- type Options
- type Renderer
- type SimpleRenderer
- func (r *SimpleRenderer) DeReference() bool
- func (r *SimpleRenderer) Indent() int
- func (r *SimpleRenderer) Path(t *types.TypeElement) []string
- func (r *SimpleRenderer) Post(t *types.TypeElement) []string
- func (r *SimpleRenderer) Pre(t *types.TypeElement) []string
- func (r *SimpleRenderer) Prefix() string
- func (r *SimpleRenderer) ProcessResult(result *types.Schema) ([]string, error)
- func (r *SimpleRenderer) SetIndent(value int)
Constants ¶
This section is empty.
Variables ¶
var SCHEMA_PATH = "components/schemas"
Default location for schema references without leading or training "/".
Functions ¶
func RenderSchema ¶
RenderStrings builds a string representation of a type result using the given pre, path, and post functions.
func RenderType ¶
func RenderType(t *types.TypeElement, r Renderer) []string
RenderType builds strings for a TypeElement and its children.
Types ¶
type JSONRenderer ¶
type JSONRenderer struct {
// contains filtered or unexported fields
}
JSONRenderer provides a simple string renderer.
func NewJSONRenderer ¶
func NewJSONRenderer(opt *Options) *JSONRenderer
func (*JSONRenderer) DeReference ¶
func (r *JSONRenderer) DeReference() bool
func (*JSONRenderer) Indent ¶
func (r *JSONRenderer) Indent() int
func (*JSONRenderer) Path ¶
func (r *JSONRenderer) Path(t *types.TypeElement) []string
Path is a function that builds a path string from a TypeElement. Format is: [<Name>:]<Type>[:<TypeRef>] - If Name is set, prefix with "Name", otherwise "-" - If TypeRef is set, suffix with "TypeRef", otherwise "-" - If Error is set, wrap entire string with "!"
func (*JSONRenderer) Post ¶
func (r *JSONRenderer) Post(t *types.TypeElement) []string
func (*JSONRenderer) Pre ¶
func (r *JSONRenderer) Pre(t *types.TypeElement) []string
func (*JSONRenderer) Prefix ¶
func (r *JSONRenderer) Prefix() string
func (*JSONRenderer) ProcessResult ¶
func (r *JSONRenderer) ProcessResult(result *types.Schema) ([]string, error)
func (*JSONRenderer) SetIndent ¶
func (r *JSONRenderer) SetIndent(value int)
type OpenAPIRenderer ¶
type OpenAPIRenderer struct { // Path URLPath string // contains filtered or unexported fields }
OpenAPIRenderer provides a simple string renderer.
func NewOpenAPIRenderer ¶
func NewOpenAPIRenderer(urlPath string, opt *Options) *OpenAPIRenderer
func (*OpenAPIRenderer) DeReference ¶
func (r *OpenAPIRenderer) DeReference() bool
func (*OpenAPIRenderer) Indent ¶
func (r *OpenAPIRenderer) Indent() int
func (*OpenAPIRenderer) Path ¶
func (r *OpenAPIRenderer) Path(t *types.TypeElement) []string
Path is a function that builds a path string from a TypeElement.
func (*OpenAPIRenderer) Post ¶
func (r *OpenAPIRenderer) Post(t *types.TypeElement) []string
func (*OpenAPIRenderer) Pre ¶
func (r *OpenAPIRenderer) Pre(t *types.TypeElement) []string
func (*OpenAPIRenderer) Prefix ¶
func (r *OpenAPIRenderer) Prefix() string
func (*OpenAPIRenderer) ProcessResult ¶
func (r *OpenAPIRenderer) ProcessResult(result *types.Schema) ([]string, error)
func (*OpenAPIRenderer) SetIndent ¶
func (r *OpenAPIRenderer) SetIndent(value int)
type Options ¶
type Options struct { // DeReference converts TypeRefs to their included types. // - If TyepRefs have a cyclical relationship, the last TypeRef is kept as a TypeRef. DeReference bool // Prefix is a string used as a prefix for indented lines. Prefix string // Indent is used for rendering where indent matters. Indent int }
func NewOptions ¶
func NewOptions() *Options
type Renderer ¶
type Renderer interface { // ProcessResult starts the render process on a Schema and returns a slice of strings. ProcessResult(result *types.Schema) ([]string, error) // DeReference returns true if schema references should be replaced with inline types. DeReference() bool // Indent returns the current indent value. Indent() int // SetIndent sets the indent to a given value. SetIndent(value int) // Prefix returns a prefix string with the current indent. Prefix() string // Pre and Post return strings before/after a type element's children are processed. Pre(t *types.TypeElement) []string Post(t *types.TypeElement) []string // Path is a function that builds a path string from a TypeElement. Path(t *types.TypeElement) []string }
type SimpleRenderer ¶
type SimpleRenderer struct {
// contains filtered or unexported fields
}
SimpleRenderer provides a simple string renderer.
func NewSimpleRenderer ¶
func NewSimpleRenderer(opt *Options) *SimpleRenderer
func (*SimpleRenderer) DeReference ¶
func (r *SimpleRenderer) DeReference() bool
func (*SimpleRenderer) Indent ¶
func (r *SimpleRenderer) Indent() int
func (*SimpleRenderer) Path ¶
func (r *SimpleRenderer) Path(t *types.TypeElement) []string
Path is a function that builds a path string from a TypeElement. Format is: [<Name>:]<Type>[:<TypeRef>] - If Name is set, prefix with "Name", otherwise "-" - If TypeRef is set, suffix with "TypeRef", otherwise "-" - If Error is set, wrap entire string with "!"
func (*SimpleRenderer) Post ¶
func (r *SimpleRenderer) Post(t *types.TypeElement) []string
func (*SimpleRenderer) Pre ¶
func (r *SimpleRenderer) Pre(t *types.TypeElement) []string
func (*SimpleRenderer) Prefix ¶
func (r *SimpleRenderer) Prefix() string
func (*SimpleRenderer) ProcessResult ¶
func (r *SimpleRenderer) ProcessResult(result *types.Schema) ([]string, error)
func (*SimpleRenderer) SetIndent ¶
func (r *SimpleRenderer) SetIndent(value int)