Forum Discussion

mma5997's avatar
mma5997
Occasional Contributor
4 years ago
Solved

How to have a custom status code in response

responses: '777': description: My Custom content: application/json: schema: type: string If I have "777" like fieldName ...
  • HKosova's avatar
    4 years ago

    OpenAPI only supports the standard HTTP status codes from the 1xx-5xx range. You can provide custom codes and messages in the body of error responses, for example:

     

          responses:
            '400':
              description: Bad request
              content:
                application/json:
                  schema:
                    type: object
                    properties:
                      code:
                        type: integer
                        example: 777
                      message:
                        type: string
                        example: Lorem ipsum