Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI 3.1: Show contentEncoding on fields if present #1666

Closed
mjpieters opened this issue Jul 2, 2021 · 1 comment · Fixed by #1700
Closed

OpenAPI 3.1: Show contentEncoding on fields if present #1666

mjpieters opened this issue Jul 2, 2021 · 1 comment · Fixed by #1700
Assignees

Comments

@mjpieters
Copy link

OpenAPI 3.1 supports JSON Schema contentEncoding to mark a field as containing non-string content, see https://json-schema.org/understanding-json-schema/reference/non_json_data.html:

The contentEncoding keyword specifies the encoding used to store the contents, as specified in [RFC 2054, part 6.1.](The contentEncoding keyword specifies the encoding used to store the contents, as specified in RFC 2054, part 6.1.)

The acceptable values are 7bit, 8bit, binary, quoted-printable and base64. If not specified, the encoding is the same as the containing JSON document.

The example used in image data, here as JSON:

{
  "type": "string",
  "contentEncoding": "base64",
  "contentMediaType": "image/png"
}

We're using "contentEncoding": "base64", to handle binary blobs for other purposes in our (non-public) API. However, the ReDoc rendering of the field doesn't reflect this:

       body:
          type:
            - string
            - 'null'
          minLength: 0
          maxLength: 100000
          contentEncoding: base64
          pattern: '^[^\0]*$'

The field is there but there is no indication that there is a content encoding specified:

image

Could this be enhanced to show that the field is expected to use base64 encoding?

@RomanHotsiy
Copy link
Member

Yes, thanks for the information.

We'll add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants