Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for root-node #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add support for root-node #10

wants to merge 1 commit into from

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