Skip to content

Add field descriptions to JSON schema #1948

@ghost

Description

A lot of tooling implementations have homegrown JSON schema definitions for the OpenAPI format, often with field descriptions providing auto complete hints. Adding object field descriptions from the specification to the JSON schema would make the JSON schema definition more attractive and cover the auto complete use-case, which might be adoption blockers for some projects. If file size is a concern maybe two separate versions with and without descriptions should be created. Object descriptions and usage examples from the spec could be added too.

For example copying the Encoding.contentType field description from https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#encoding-object

Encoding:
    type: object
    properties:
      contentType:
        type: string
        description: "The Content-Type for encoding a specific property. Default value depends on the property type: for `string` with `format` being `binary` – `application/octet-stream`; for other primitive types – `text/plain`; for `object` - `application/json`; for `array` – the default is defined based on the inner type. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types."
      headers:
        type: object
        additionalProperties:
          $ref: '#/definitions/Header'
      style:
        type: string
        enum:
          - form
          - spaceDelimited
          - pipeDelimited
          - deepObject
      explode:
        type: boolean
      allowReserved:
        type: boolean
        default: false
    additionalProperties: false

Example result:
Screenshot from 2019-06-13 01-39-19

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