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

Allows references that point to parent definitions #39

Merged
merged 4 commits into from
Feb 26, 2017

Conversation

alindeman
Copy link
Contributor

@alindeman alindeman commented Feb 26, 2017

Fixes #29

Highlights

  • Introduces a ResolvedSet structure to mark references that have been (or are currently being) resolved, to avoid infinite loops.
  • Resolves references eagerly before child elements are resolved. This is more in line with the spec, which states that elements with $ref should be replaced entirely with the representation that they point to.

Note that this still doesn't quite correctly generate the Heroku Platform API schema due to bugs in the schema itself (missing type information on some schemas). I've submitted a PR against the API to get that issue addressed, but until it's merged I've created a gist of the schema.json from my PR branch to test against.

* Introduces a `resolvedSet` structure to mark references that have been (or
  are currently being) resolved, to avoid infinite loops.
* Resolves references eagerly before child elements are resolved. This is more
  in line with [the spec], which states that elements with `$ref` should be
  replaced entirely with the representation that they point to.

[the spec]: https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.28
Copy link
Member

@cyberdelia cyberdelia left a comment

Choose a reason for hiding this comment

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

A few talking point, but looks fine.
Thank you very much!

.travis.yml Outdated
install: go get code.google.com/p/go.tools/cmd/cover
- 1.7
- 1.8
install: go get golang.org/x/tools/cmd/cover
Copy link
Member

Choose a reason for hiding this comment

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

You should able to drop this line entirely, cover no longer requires to be installed.

gen.go Outdated
@@ -18,13 +18,23 @@ func init() {
templates = template.Must(bundle.Parse(templates))
}

// resolvedSet stores a set of pointers to objects that have already been
// resolved to prevent infinite loops.
type resolvedSet map[interface{}]bool
Copy link
Member

Choose a reason for hiding this comment

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

Should this be exported, considering it's used in an exported function later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think you're right. Good catch. Fixed.

@alindeman
Copy link
Contributor Author

@cyberdelia Thanks for the review. I pushed a couple of new commits based on your feedback.

@cyberdelia
Copy link
Member

Lovely!

Do you mind sharing a gist of the diff between your schema and the API one? It would help me plead your case on Monday.

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.

Stack overflow by $ref in targetSchema
2 participants