Skip to content

content_element could be an anyOf definition #225

@mauro-moreno

Description

@mauro-moreno

content_elements is defined in trait_content_element.json as an array of content_element defined in utils/content_element.json. But, what specificiation doesn't explain is that could also be replaced by any schema defined in story_elements

Should not be the definition of content_element the reference to any of that schemas?

Current behavior:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/utils/content_element.json",
  "title": "An element that can be listed as part of content elements",
  "description": "An item that conforms to this schema can be rendered in a sequence",
  "type": "object",
  "additionalProperties": {},
  "properties": {
    "type": {
      "type": "string"
    },
    "_id": {
      "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_id.json"
    },
    "subtype": {
      "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_subtype.json"
    },
    "channels": {
      "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_channel.json"
    },
    "alignment": {
      "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_alignment.json"
    },
    "additional_properties": {
      "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_additional_properties.json"
    },
    "gallery_properties": {
      "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_gallery_properties.json"
    }
  },
  "required": [ "type" ]
}

Expected behavior:

{
  "anyOf": [
    {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "id": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/utils/content_element.json",
      "title": "An element that can be listed as part of content elements",
      "description": "An item that conforms to this schema can be rendered in a sequence",
      "type": "object",
      "additionalProperties": {},
      "properties": {
        "type": {
          "type": "string"
        },
        "_id": {
          "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_id.json"
        },
        "subtype": {
          "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_subtype.json"
        },
        "channels": {
          "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_channel.json"
        },
        "alignment": {
          "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_alignment.json"
        },
        "additional_properties": {
          "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_additional_properties.json"
        },
        "gallery_properties": {
          "$ref": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.5/traits/trait_gallery_properties.json"
        }
      },
      "required": [ "type" ]
    },
    {
      "$ref": "https://github.com/washingtonpost/ans-schema/blob/master/src/main/resources/schema/ans/0.10.5/story_elements/blockquote.json"
    },
    {
      "$ref": "https://github.com/washingtonpost/ans-schema/blob/master/src/main/resources/schema/ans/0.10.5/story_elements/code.json"
    }
    ...
  ]
}

Use case:
I'm using a mapping tool from json schema to classes and I have to import all that schemas apart because they are not referenced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions