Skip to content

karuppiah7890/go-jsonschema-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-jsonschema-generator Build Status GoDoc

Basic json-schema generator based on Go types, for easy interchange of Go structures across languages.

Installation

The recommended way to install go-jsonschema-generator

go get github.com/mcuadros/go-jsonschema-generator

Examples

A basic example:

package main

import (
  "fmt"
  "github.com/mcuadros/go-jsonschema-generator"
)

type EmbeddedType struct {
  Zoo string
}

type ExampleBasic struct {
  Foo bool   `json:"foo"`
  Bar string `json:",omitempty"`
  Qux int8
  Baz []string
  EmbeddedType
}

func main() {
  s := &jsonschema.Document{}
  s.Read(&ExampleBasic{})
  fmt.Println(s)
}
{
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "Bar": {
            "type": "string"
        },
        "Baz": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "Qux": {
            "type": "integer"
        },
        "Zoo": {
            "type": "string"
        },
        "foo": {
            "type": "bool"
        }
    },
    "required": [
        "foo",
        "Qux",
        "Baz",
        "Zoo"
    ]
}

License

MIT, see LICENSE

About

json-schemas generator based on Go types

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%