Ask a Question

Swagger response for invalid type arguments

NennoMP
Occasional Visitor

Swagger response for invalid type arguments

Hello, I want to handle specific cases in which the type of the arguments of the body is wrong (string instead of integer, for example). When I try this I get a server error 500, How can I customize a response for the situation mentioned above? I would like to return a client side error, since the problem is that the type of the input is wrong. 

I know I could remove the type and do the checks in the code, but I would prefer to avoid this.

 

I have the following configuration file:

 

paths:
  /test:
    post:
      operationId: monolith.views.test.test_endpoint
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/test_schema'
      responses:
        200:
          description: Return ok
        422:
          description: Invalid paramaters, return message error
        default:
          description: An error occurred

components:
  schemas:
    test_schema:
      required:
        - test_value
      type: object
      properties:
        test_value:
          type: integer
          example: 5

 

 

 

I am developing this in Python and I am also using Connexion. Thanks in advance.

0 REPLIES 0
cancel
Showing results for 
Search instead for 
Did you mean: