Skip to content

Conversation

@sopak
Copy link

@sopak sopak commented Mar 30, 2017

In some cases I can get json with multiple schemas for example REST definition GET/POST/DELETE etc.
This change will try to find node in json and use it as schema.

In some cases  I can get json with multiple schemas  for example  REST definition  GET/POST/DELETE etc.
This change will try to find node in json and  use it as  schema.
Copy link
Owner

@idubinskiy idubinskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

This will only look at top-level nodes, so that should probably be clarified somewhere. Probably the command line flag description or README. Or both. Either way, please update the README.

log.Fatalln("Error parsing JSON:", err)
}
node, ok := sub[*rootNodeName]
if ok == false {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be !ok.

if err = json.Unmarshal(file, &s); err != nil {
log.Fatalln("Error parsing JSON:", err)
if *rootNodeName != "" {

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this empty line.

}
node, ok := sub[*rootNodeName]
if ok == false {
log.Fatalln(fmt.Sprintf("Error JSON node '%s' does not exists:", *rootNodeName), err)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of combining log.Fatalln and fmt.Sprintf, use log.Fatalf. Don't forget to add \n at the end of the format string.

if ok == false {
log.Fatalln(fmt.Sprintf("Error JSON node '%s' does not exists:", *rootNodeName), err)
}
//log.Panicf("Error reading file %v:", node)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants