smizell / hyperschema.org

Hyperschema.org Site
6 stars 3 forks source link

Incorrect linkObject schema definition #4

Closed benfalk closed 7 years ago

benfalk commented 8 years ago

The linkObject says that a href can only have oneOf the following properites

    "linkObject": {
      "title": "HAL Link Object",
      "description": "An object with link information",
      "type": "object",
      "properties": {
        "name": { "$ref": "http://hyperschema.org/core/base#/definitions/name" },
        "href": {
          "oneOf": [
            { "$ref": "http://hyperschema.org/core/link#/definitions/href" },
            { "$ref": "http://hyperschema.org/core/link#/definitions/hrefTemplated" }
          ]
        },
        "templated": { "$ref": "http://hyperschema.org/core/link#/definitions/isTemplated" },
        "type": { "$ref": "http://hyperschema.org/core/base#/definitions/mediaType" },
        "deprecation": { "$ref": "http://hyperschema.org/core/link#/definitions/isDeprecated" }
      },
      "required": [ "href" ]
    }

( Source https://github.com/smizell/hyperschema.org/blob/master/src/mediatypes/hal.json#L33-L34 )

The problem with this that any correct value you use for href will match both href and hrefTemplated because the are said to both be strings. Because it will always match both instead of one or the other this linkObject definition will never validate data because the href is required and will always match both instead of one or the other.

  "definitions": {
    "href": {
      "title": "HREF",
      "description": "A hyperlink URL",
      "type": "string"
    },
    "hrefTemplated": {
      "title": "Templated HREF",
      "description": "A hyperlink that is a URI template (RFC 6570)",
      "type": "string"
    },

( Source https://github.com/smizell/hyperschema.org/blob/master/src/core/link.json#L2-L12)

Looking at what is drafted up here: https://github.com/json-schema/json-schema/wiki/anyOf,-allOf,-oneOf,-not

I would suggest using anyOf for the href instead of oneOf

wingedfox commented 8 years ago

Hi,

+1, will there be a fix for this issue? HAL schema is useless as by now without the fix.

yaccob commented 7 years ago

+1

smizell commented 7 years ago

Fixed by PR #5. Thanks everyone.