Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Not sure if root properties next to 'allOf' make sense #23

Open
postatum opened this issue Sep 15, 2016 · 0 comments
Open

Not sure if root properties next to 'allOf' make sense #23

postatum opened this issue Sep 15, 2016 · 0 comments
Labels

Comments

@postatum
Copy link
Contributor

This applied to anyOf/oneOf/allOf.
Having RAML type:

Cat:
  type: object
  maxProperties: 1
  properties:
    rating:
      type: string | integer

Canonical form will be:

{
  "additionalProperties": true,
  "maxProperties": 1,
  "type": "union",
  "anyOf": [
    {
      "properties": {
        "rating": {
          "type": "string",
          "required": true
        }
      },
      "additionalProperties": true,
      "maxProperties": 1,
      "type": "object"
    },
    {
      "properties": {
        "rating": {
          "type": "integer",
          "required": true
        }
      },
      "additionalProperties": true,
      "maxProperties": 1,
      "type": "object"
    }
  ]
}

As you can see, schemas in anyOf duplicate all params of root object like maxProperties.
Considering that using union adds multiple copies of that object to anyOf and to be valid instance has to be valid to any of them, does it make sense to keep root properties when anyOf is present?
As I imagine it maxProperties or additionalProperties will not be used in validation, because instance will be validated against schemas from anyOf.
I may be wrong here.

@jstoiko jstoiko added the 0.1.x label Aug 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants