Skip to content

"type" in schema JSON objects should only be allowed to be a string. #531

Description

@KitFieldhouse

Hey all!

This implementation allows us to parse a schema of the form:

{
    "type":  { 
                       ....some correct schema here
     }
}

for instance, in this implementation, we can parse

{
    "type":  { 
                       "type": "enum",
                       "name": "testEnum",
                       "symbols": ["A","B","C"]
                   }
}

however, in the Java implementation this fails with:

No type: {"type":{"type":"enum","name":"testEnum","symbols":["A","B","C"]}}

From the spec :

A Schema is represented in JSON by one of:

  • A JSON string, naming a defined type.
  • A JSON object, of the form:

{"type": "typeName", ...attributes...}

where typeName is either a primitive or derived type name, as defined below. Attributes not defined in this document are permitted as metadata, but must not affect the format of serialized data.

  • A JSON array, representing a union of embedded types.

which, in my reading, makes it clear that when we are inside a JSON object as a schema, "type" can only be a string that equals a type name.

What seems to be vague in the specification is if this type name should only be allowed to be a built-in type name or if user defined type names are allowed. My belief is that the rational option is to only allow built-in type names. I opened a Jira issue about this ambiguity in the spec.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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