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/json, text/plain) that 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
type: string
'500':
description: Internal Server Error
content:
application/json:
schema:
properties:
message:
description: Error message
type: string
To make sure that we haven't forgotten any responses, we can check our request handler (src/handlers/auth/salt/retrieve/index.js), our middleware, as well as our E2E tests.
We have now defined the Get Salt endpoint with the OpenAPI specification language. Let's move on to a slightly more complicated endpoint—Create User—and see how we can specify payload bodies.