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

BUG :: json-schema constraints don't allow for variations in message types #8

Closed
gdbrown opened this issue Apr 3, 2016 · 2 comments
Assignees
Labels

Comments

@gdbrown
Copy link
Contributor

gdbrown commented Apr 3, 2016

When a field of type "message" is used it creates an inline reference which points to an exact version of the message schema. This makes validation problematic as the message isn't likely to always be the same version.

    "ctx_cloud": {
      "type": "object",
      "description": "The \"ctx_cloud\" is set by the server receiving the command and is generally only used internally for tracking and performance monitoring.",
      "anyOf": [
        {
          "$ref": "#/definitions/cloud"
        }
      ],
      "pbj": {
        "type": "message",
        "rule": "single"
      }
    },

inline definitions:

  "definitions": {
    "app": {
      "$ref": "https://schemas.gdbots.io/gdbots/contexts/app/1-0-0.json"
    },
    "cloud": {
      "$ref": "https://schemas.gdbots.io/gdbots/contexts/cloud/1-0-0.json"
    }
  },

In order to make this still validate the field properly and allow for multiple version the definition itself should be an anyOf that allows for any version of the message type.

Using the curie you can get a reference for all versions of the message and generate that array. Php solves this with an interface (one without the version)... json schema has no way to describe "so long as it's a blah, accept it, regardless of version)".

@excelwebzone
Copy link
Contributor

I can point the ref to the laterst.json or I can also create a v<major>.json and point to that?

@gdbrown
Copy link
Contributor Author

gdbrown commented Apr 4, 2016

it must be able to validate against any of that message. latest pins it at only one version and json schema doesn't render a curie major rev.

we'd either have to render a curie major json schema file OR the anyOf points to all available versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants