Skip to content

Multi lingual annotations #10

Open
@stueynz

Description

@stueynz

Historically OpenAPI and JSON Schema have worked together to document existing APIs. In a contract first environment they are being asked to do more than merely document existing APIs; they are defining APIs that are yet to be built. JSON Schema is no longer just about payload validation, the annotations in a JSON Schema complete the definition of the payloads sufficient to define APIs that are yet to be built.

When defining enumeration values, JSON Schema lets us give each enumeration value annotations:

  type: object
  properties:
    Name:
      type: string
    Gender:
       type: string
       oneOf: 
         - const: "M"
           title: "Male"
         - const: "F"
           title: "Female"
         - const: "D"
           title: "Diverse"
           description: "Used where gender known, and is non-binary"

When JSON Schema is used to define APIs and message payloads, it is not unreasonable for software developers to choose to populate user interface elements (radio buttons, drop down lists, etc.) from the annotation values presented in the JSON schema. In a multi-lingual environment, we may need multiple annotations, keyed by language.

Expanding the definition of the title (and perhaps description) annotations to be either a single string or an object with properties keyed on language tags would be a good idea:

  type: object
  properties:
    Name:
      type: string
    Gender:
       type: string
       oneOf: 
         - const: "M"
           title: {"en-NZ": "Male", "mi-NZ": "Tāne" }
         - const: "F"
           title: {"en-NZ": "Female", "mi-NZ": "Wahine" }
         - const: "D"
           title: {"en-NZ": "Diverse", "mi-NZ": "Ira tāngata kōwhiri kore" }
           description: "Used where gender known, and is non-binary"

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