Forum Discussion

Nixol's avatar
Nixol
Occasional Contributor
5 years ago
Solved

OpenAPi 3.0.3 - can I use two POST methods for the same path - each with its own request body?

can I use two POST methods for the same path with each operation having its own request body?  If it is not possible, how cab I achieve this?  I use OpenApi 3.0.3

5 Replies

  • Hi purvaweaveshome 

    To improve performance, consider optimizing your testing strategy. You can start by staggering test execution times to avoid overlaps, which can put a heavy load on your system.

    Hope this helps - Happy to help further!!
    Thank you very much and have a great one!
    Warm regards

  • OpenAPI only allows one POST/GET/etc. operation per path, but you can define multiple possible request bodies by using oneOf:

    paths:
      /something:
        post:
          operationId: createSomething
          requestBody:
            required: true
            content:
              application/json:
                schema:
                  oneOf:
                    - $ref: '#/components/schemas/Body1'
                    - $ref: '#/components/schemas/Body2'