-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Test case
Use the following code to generate the data structures
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
jsonschema "github.com/tfkhsr/jsonschema"
golang "github.com/tfkhsr/jsonschema/golang"
)
func main() {
url := "https://raw.githubusercontent.com/microsoft/botframework-sdk/master/schemas/protocol/botframework.json"
fmt.Println("fetch", url)
response, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
schema, _ := ioutil.ReadAll(response.Body)
idx, err := jsonschema.Parse(schema)
if err != nil {
panic(err)
}
src, err := golang.PackageSrc(idx, "bot")
if err != nil {
panic(err)
}
output := "data.go"
fmt.Println("writing", output)
err = ioutil.WriteFile(output, src, 0644)
if err != nil {
panic(err)
}
fmt.Println("done")
}The generated data.go file is broken
Duplicates
Contains duplicates like:
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardAction
type Buttons []CardActionWrong Property used
The generated code mixes the names of the created properties, eg. ConversationAccount and Conversation, see the following code generated:
type Activity struct {
...
Conversation *ConversationAccount `json:"ConversationAccount,omitempty"`
...
}and
func (t *Activity) Validate() error {
...
err = t.ConversationAccount.Validate()
...
}Metadata
Metadata
Assignees
Labels
No labels