Transform your JSON Schema draft-07 to OpenAPI 3.0
PutSchemaIntoOpenAPI will put definitions from provided JSON Schema into your OpenAPI 3.0 specification component.schemas. Also it will
- Cleanup any
$schemaor other keys from JSON Reference objects - Any reference to
#/definitionswill lead to#/component/schemas "oneOf": [{"type": X}, {"type": "null"}]will be replaced with"type": X, "nullable": trueoneOfwith multipleifs inside around one property with different values, will be transformed to oneOf with discriminate, see here
go get github.com/bunyk/jsonschema2openapi
import (
"fmt"
"github.com/bunyk/jsonschema2openapi"
)
..
APISpec, err := PutSchemaIntoOpenAPI(schema, openapitemplate)
if err == nil {
fmt.Println(APISpec)
} else {
fmt.Println(err.Error())
}See more complete example in docs: https://godoc.org/github.com/bunyk/jsonschema2openapi#PutSchemaIntoOpenAPI