You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generated JSON schema files are converted to all lowercase file names. This can break JSON schema references if capital letters are used in OpenAPI reference names.
Expected behavior
Maintain the same casing for generated JSON schema file names as defined in OpenAPI definitions.
Steps to reproduce
# Requires Go version 1.11 to use Go modules.
pip install openapi2jsonschema==0.8.0
openapi2jsonschema schema.yaml -o output
go mod init github.com/random/testing
go build schema.go
./schema
compile error: open /<full-file-path>/output/RequestData.json: no such file or directory
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6e8558]
goroutine 1 [running]:
github.com/xeipuuv/gojsonschema.(*Schema).validateDocument(0x0, 0x746e40, 0xc0000934a0, 0x0)
/root/go/pkg/mod/github.com/xeipuuv/[email protected]/validation.go:72 +0x78
github.com/xeipuuv/gojsonschema.(*Schema).Validate(0x0, 0x80f880, 0xc00008f880, 0x1, 0x1, 0x63)
/root/go/pkg/mod/github.com/xeipuuv/[email protected]/validation.go:64 +0x6b
main.main()
/<full-file-path/schema.go:13 +0x1cb
// schema.go
//
// Modify the full file path below to point to generated all.json file.
package main
import (
"fmt"
"github.com/xeipuuv/gojsonschema"
)
func main() {
sl := gojsonschema.NewSchemaLoader()
schema, err := sl.Compile(
gojsonschema.NewReferenceLoader("file:///<full-file-path>/output/all.json"))
fmt.Printf("compile error: %s\n", err)
document := gojsonschema.NewStringLoader(`{"type": "string"}`)
result, err := schema.Validate(document)
if result.Valid() {
fmt.Printf("document is valid\n")
} else {
fmt.Printf("document is not valid\n")
}
}
Include schemas from:
paths/<path>/<httpmethod>/requestBody/content/<mimetype>/schema
paths/<path>/<httpmethod>/responses/<httpcode>/content/<mimetype>/schema
Closesinstrumenta#25
Do not downcase filenames
Closesinstrumenta#20
Move new functionality to separate function
Make "content" key in body definition optional
This was committed as a GitHub review suggestion.
Commit message suggested by Github:
Update openapi2jsonschema/util.py
Co-authored-by: Adam Kitain <[email protected]>
Description
Generated JSON schema files are converted to all lowercase file names. This can break JSON schema references if capital letters are used in OpenAPI reference names.
Expected behavior
Maintain the same casing for generated JSON schema file names as defined in OpenAPI definitions.
Steps to reproduce
The text was updated successfully, but these errors were encountered: