Skip to content

bunyk/jsonschema2openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transform your JSON Schema draft-07 to OpenAPI 3.0

Build Status GoDoc

PutSchemaIntoOpenAPI will put definitions from provided JSON Schema into your OpenAPI 3.0 specification component.schemas. Also it will

  • Cleanup any $schema or other keys from JSON Reference objects
  • Any reference to #/definitions will lead to #/component/schemas
  • "oneOf": [{"type": X}, {"type": "null"}] will be replaced with "type": X, "nullable": true
  • oneOf with multiple ifs inside around one property with different values, will be transformed to oneOf with discriminate, see here

Installation

go get github.com/bunyk/jsonschema2openapi

Usage example

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

About

Transform your JSON Schema draft-07 to OpenAPI 3.0

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages