Skip to content

Ambiguity between JSON string and plain string #2349

Closed
@letmaik

Description

@letmaik

The following is in the 3.1 dev spec:

{
  "description": "A simple string response",
  "content": {
    "text/plain": {
      "schema": {
        "type": "string"
      }
    }
  }

}

The intention is that the response body contains an arbitrary string, e.g.:

Hello world!

However, this would be invalid given the above JSON schema. A correct response would be:

"Hello world!"

It seems like the spec ignores this inconsistency and somehow implicitly turns JSON schema off in cases where the type is primitive (or just for strings?). The same is true here:

content:
    image/png:
        schema:
            type: string
            contentEncoding: base64

A valid body would be:

"SGVsbG8gd29ybGQh"

But that is again not the intention here.

In summary, I'm missing some language in the spec that describes this behavior explicitly.

Slightly unrelated, there's another example which confuses me:

{
  "description": "user to add to the system",
  "content": {
    "text/plain": {
      "schema": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    }
  }
}

Is this supposed to be for example ["Hello", "world!"]? If so, why is the content type text/plain instead of application/json?

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