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

Nested refs not resolved correctly when schema supplied as string #446

Closed
chefhoobajoob opened this issue Nov 16, 2015 · 9 comments
Closed
Milestone

Comments

@chefhoobajoob
Copy link

This schema fails with "URI is not absolute":

{
  "definitions": {

    "RefA": {
      "properties": {
        "something": {
          "type": "string"
        }
      }
    },

    "RefB": {
      "properties": {
        "b2a": {
          "$ref": "#/definitions/RefA"
        }
      }
    }
  },

  "type": "object",
  "properties": {
    "root2RefB": {
      "$ref": "#/definitions/RefB"
    }
  }
}
@joelittlejohn
Copy link
Owner

Hi, which version are you using? (or are you using the web app?) There was an issue like this fixed recently.

@chefhoobajoob
Copy link
Author

This is the web site

@joelittlejohn
Copy link
Owner

I think you're hitting #250. This should be fixed when I update the site to the latest version. Thanks for reporting this.

@chefhoobajoob
Copy link
Author

Ok - I'll keep my eye out for it. Thanks!

@joelittlejohn
Copy link
Owner

I've updated the site to the latest plugin version (0.4.16) so you should be good to go. I've tested your schema and seen some generated output.

@chefhoobajoob
Copy link
Author

Ok, it seems that while it does seem to generate types for the schema above, it runs into a different (?) problem with the schema below.

The error I'm getting from the site is: There's a problem: Path not present: definitions. Should I open a separate issue?

{
   "$schema": "http://json-schema.org/draft-04/schema#",

   "definitions": {
     "Namespace": {
       "type": "string",
       "pattern": "^[a-zA-Z_]([0-9a-zA-Z-_.])+[a-zA-Z0-9_]$"
     },
     "Name": {
       "type": "string",
       "pattern": "^[a-zA-Z_]([0-9a-zA-Z-_])+[a-zA-Z0-9_]$"
     },
     "Version": {
       "type": "string",
       "pattern": "^\\d+\\.\\d+\\.\\d+(-([0-9A-Za-z-.]*[0-9a-zA-Z])+)*$"
     },
     "Thing": {
       "properties": {
         "namespace": { "$ref": "#/definitions/Namespace" },
         "name": { "$ref": "#/definitions/Name" },
         "version": { "$ref": "#/definitions/Version"}
       },
       "required": ["namespace", "name", "version"]
     },
     "ThingList": {
       "type": "array",
       "items": { "$ref": "#/definitions/Thing" },
       "minItems": 1
     }
   },
  "type": "object",
  "properties": {
    "things": { "$ref": "#/definitions/ThingList" }
  },
  "required": ["things"]
}

@chefhoobajoob
Copy link
Author

For reference, I can drop that schema here with the object below, and it parses the schema and validates the object without error, so I don't think the problem is in the schema definition itself:

{
  "things": [
    {
       "namespace": "wonky.butt-nugget",
       "name": "bubbly",
       "version": "1.2.3-rc.1"
    }
  ]
}

@joelittlejohn joelittlejohn added this to the 0.4.17 milestone Nov 29, 2015
@joelittlejohn
Copy link
Owner

Thanks for the update. I've had a look into this and I can definitely see a problem. It relates to how nested refs are resolved when there is no file but just a string given directly to the plugin (this is how the website works).

I've resolved this using your example so it will be released in the next version. Cheers

@chefhoobajoob
Copy link
Author

ok - thanks!

@joelittlejohn joelittlejohn changed the title jsonschema2pojo.org: refs within definitions to other definitions fails Nested refs not resolved correctly when schema supplied as string Dec 2, 2015
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