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

$ref works with external files? #41

Closed
maurogeorge opened this issue Dec 10, 2015 · 2 comments
Closed

$ref works with external files? #41

maurogeorge opened this issue Dec 10, 2015 · 2 comments

Comments

@maurogeorge
Copy link

Hi guys,

I think I found a issue, with a response:

{"name":1,"description":"Description 1"}

And passing the file

{
  "properties": {
    "name": {
      "$ref": "test/support/schemas/custom/show.json#/properties/name"
    },
    "description": {
      "$ref": "test/support/schemas/custom/show.json#/properties/description"
    }
  }
}
# test/support/schemas/custom/show.json

{
  "properties": {
    "name" : { "type" : "string" },
    "description" : { "type" : "string" }
  }
}

This is valid on json_schema, as you can see the name on response is a integer and in the schema is a string. If I change the schema to this:

{
  "properties": {
    "name" : { "type" : "string" },
    "description": {
      "$ref": "test/support/schemas/custom/show.json#/properties/description"
    }
  }
}

I got the expected error.

After some debug if I change the $ref to non existent files, it is still considered a valid response:

{
  "properties": {
    "name": {
      "$ref": "foo"
    },
    "description": {
      "$ref": "bar"
    }
  }
}

I only got a error RuntimeError: RuntimeError: #: "test/support/schemas/custom/show.json#/properties" is not a valid schema. when I change the schema to this:

{
  "properties": {
    "$ref": "test/support/schemas/custom/show.json#/properties"
  }
}

If I change the value to /test/support/schemas/custom/show.json#/properties, /custom/show.json#/properties or custom/show.json#/properties always I got the error, never is found the file.

Thanks for the working on the project.

@brandur
Copy link
Owner

brandur commented Dec 14, 2015

Hey @maurogeorge, building this I kind of made a decision to not try to expand and resolve all references automatically given that you're allowed to use URIs and this kind of thing in them. The result is that this is a slightly more manual process than what may be optimal in some cases.

Can you check out #22 and see if it helps your case at all?

maurogeorge added a commit to maurogeorge/active_model_serializers that referenced this issue Dec 21, 2015
After some debug was discovered that the JSON pointers are not working [1].

This patch make the JSON Pointers working again following the recommendation
from @brandur [2].

As a note json_matchers has a issue that they are doing the movement from
json-schema to json_schema [3].

[1]: 0852b49#commitcomment-14792738
[2]: brandur/json_schema#41 (comment)
[3]: thoughtbot/json_matchers#31
@maurogeorge
Copy link
Author

Thanks a lot @brandur with the content of #22 I can solve my problem.

Thanks ❤️

maurogeorge added a commit to maurogeorge/active_model_serializers that referenced this issue Dec 22, 2015
After some debug was discovered that the JSON pointers are not working [1].

This patch make the JSON Pointers working again following the recommendation
from @brandur [2].

As a note json_matchers has a issue that they are doing the movement from
json-schema to json_schema [3].

[1]: 0852b49#commitcomment-14792738
[2]: brandur/json_schema#41 (comment)
[3]: thoughtbot/json_matchers#31
maurogeorge added a commit to maurogeorge/active_model_serializers that referenced this issue Dec 23, 2015
After some debug was discovered that the JSON pointers are not working [1].

This patch make the JSON Pointers working again following the recommendation
from @brandur [2].

As a note json_matchers has a issue that they are doing the movement from
json-schema to json_schema [3].

[1]: 0852b49#commitcomment-14792738
[2]: brandur/json_schema#41 (comment)
[3]: thoughtbot/json_matchers#31
maurogeorge added a commit to maurogeorge/active_model_serializers that referenced this issue Jan 6, 2016
After some debug was discovered that the JSON pointers are not working [1].

This patch make the JSON Pointers working again following the recommendation
from @brandur [2].

As a note json_matchers has a issue that they are doing the movement from
json-schema to json_schema [3].

[1]: 0852b49#commitcomment-14792738
[2]: brandur/json_schema#41 (comment)
[3]: thoughtbot/json_matchers#31
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