Specifying responses

Next, we need to specify what our endpoint can potentially respond with. This is a required field for all operation objects. The responses Object is a map of numeric HTTP status codes and a response object, which should contain two fields:

  • description: A short description of the payload
  • content (object): This specifies the valid MIME types (for example, application/jsontext/plainthat are acceptable for this endpoint, as well as the expected structure of the payload:
paths:  /salt:    get:      ...      responses:        '200':          description: Salt Retrieved          content:            text/plain:              schema:                type: string        '400':          description: Email query parameter not specified          content:            application/json:              schema:                properties:                  message: description: Error message ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.