fastify/help

swagger with multiple requestBody

pkpritam3 opened this issue · 0 comments

How can I implement below using fastify-swagger where we have multiple requestBody contents?

openapi: 3.0.1
info:
  title: Test API
  description: API documentation
  version: 1.0.0
paths:
  /your-endpoint:
    post:
      summary: Endpoint to handle multiple content types
      tags:
        - test
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                key:
                  type: string
              required:
                - key
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
              required:
                - file
          text/plain:
            schema:
              type: string
      responses:
        '200':
          description: Successful response
          content:
            application/hal+json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  data:
                    type: object
                    additionalProperties: true
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Unsupported content type