Forum Discussion

mma5997's avatar
mma5997
Occasional Contributor
5 years ago

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
    5 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