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

Problems with $ref schema urls in Rails test environment #65

Open
apsoto opened this issue Jul 31, 2013 · 1 comment
Open

Problems with $ref schema urls in Rails test environment #65

apsoto opened this issue Jul 31, 2013 · 1 comment

Comments

@apsoto
Copy link
Contributor

apsoto commented Jul 31, 2013

Here's my situation:

I have a Rails controller that generates various schemas.

In one such schema, I $ref another schema. The $ref url is generated using the typical Rails url helpers.

The problem arises when I try to run some tests that try to validate some data against the schemas. Since it's running in Rails TEST environment, the generated url's have 'www.example.com' as the HOST. When json-schema tries to open the $ref'ed URL, it gets a 404.

{
  "properties": {
    "foo" : { "$ref" : "http://www.example.com/schemas/foo.json" }
  }
}

I've come up with a hack to work around this, but I think the 'right' solution would be if json-schema had a means of providing pluggable URL resolvers for this type of situation.

I'm considering submitting a patch for this, but I'd like to hear anyone's thoughts on this idea or alternative solutions.

@hoxworth
Copy link
Contributor

I think that's a great idea. I'd really like to take some time and clean up the external schema referencing anyway, and provide some security flags / options around it to avoid following links, etc.

@pd pd mentioned this issue Nov 3, 2014
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

No branches or pull requests

2 participants