Issue with Inclusion of Empty metadata Field in API Calls Using OpenAPI Specification

Hello everyone,

I am encountering a recurring issue with my GPT Tool, which involves the non-inclusion of the metadata field when it is empty, despite being specified in my OpenAPI schema. Here’s a brief overview of the situation:

Problem Description: My API schema specifies that the metadata object must always be included in the payload of the booking endpoint, even if it is empty. This is critical for our processing logic. However, the automated system or tool that generates and sends API calls (possibly a GPT or similar AI model) consistently omits this field when it contains no data ({}), despite the OpenAPI specification explicitly marking it as required with a default empty object.

Schema Snippet:

metadata:
  type: object
  description: Additional metadata for the booking, returned even if empty.
  additionalProperties: true
  default: {}
  example: {}
  minProperties: 0

Expected Behavior: The API call payloads should always include the metadata field, even if the actual metadata content is an empty object ({}).

Actual Behavior: The metadata field is omitted entirely from the API calls when there are no properties to include in it, despite defaults and examples provided in the specification.

Troubleshooting Steps Taken:

  • Ensured that metadata is explicitly marked as required in the OpenAPI schema.
  • Added default and example values to encourage inclusion even when empty.
  • Checked serialization settings in the client library to ensure empty objects are not omitted.

Questions:

  1. Is there a known issue with certain tools or libraries not respecting the default field in OpenAPI schemas for empty objects?
  2. Are there specific settings or practices recommended to ensure that empty but required objects are included in API calls generated from OpenAPI specifications?

Any insights or suggestions on how to ensure consistent inclusion of the metadata field in API calls would be greatly appreciated. Thank you!

Full Schema for reference, issue can be located where path is /booking


openapi: 3.0.0
info:
  title: Calendar and Booking API
  description: This API allows users to check available slots and book them based on their preferences.
  version: 1.0.0
servers:
  - url: https://api.cal.com
    description: Cal.com API endpoint for accessing calendar and available slots and create bookings/meetings
paths:
  /slots:
    get:
      summary: Retrieve available slots based on the user's specified date range.
      operationId: getAvailableSlots
      parameters:
        - name: apiKey
          in: query
          required: true
          description: API key needed to authorize the request. Ensure this parameter is included in the query string.
          schema:
            type: string
            default: #####
        - name: eventTypeId
          in: query
          required: true
          description: The ID of the event type to check availability for. This parameter is fixed at 594990.
          schema:
            type: integer
            default: 594990
        - name: startTime
          in: query
          required: true
          description: The start date for the date range in YYYY-MM-DD format. Replace 'YYYY-MM-DD' with the desired start date.
          schema:
            type: string
            format: date
        - name: endTime
          in: query
          required: true
          description: The end date for the date range in YYYY-MM-DD format. Replace 'YYYY-MM-DD' with the desired end date.
          schema:
            type: string
            format: date
        - name: timeZone
          in: query
          required: true
          description: The time zone in which the times are specified, e.g., 'Europe/London'. Ensure to replace this with the
            actual time zone required for the request.
          schema:
            type: string
            example: Europe/London
      responses:
        "200":
          description: Returns a list of available time slots within the specified date range.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
                  description: Available time slot
        "400":
          description: Invalid request parameters or no slots available for the given criteria.
  /bookings:
    post:
      summary: Create a new booking/meeting for a user based on users selected slots.
      operationId: createBooking
      parameters:
        - name: apiKey
          in: query
          required: true
          description: API key needed to authorize the request. Ensure this parameter is included in the query string.
          schema:
            type: string
            default: ######
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                eventTypeId:
                  type: integer
                  description: The ID of the event type to book.
                  example: 2323232
                start:
                  type: string
                  format: date-time
                  description: Start time of the booking slot in ISO 8601 format.
                  example: 2023-05-24T13:00:00.000Z
                end:
                  type: string
                  format: date-time
                  description: End time of the booking slot in ISO 8601 format.
                  example: 2023-05-24T13:30:00.000Z
                responses:
                  type: object
                  properties:
                    name:
                      type: string
                      description: Name of the person booking the slot.
                      example: Hello Hello
                    email:
                      type: string
                      description: Email address of the person booking the slot.
                      example: hello@gmail.com 
                    location:
                      type: string
                      description: Location of the booking, always virtual.
                      example: virtual
                timeZone:
                  type: string
                  description: Time zone for the booking time.
                  example: Europe/London
                language:
                  type: string
                  description: Language preference for the booking. English would be "en" as standard.
                  example: en
                metadata:
                  type: object
                  nullable: true
                  description: Additional metadata for the booking. It must always be included in the request, even if empty. By default, it includes a 'placeholder' key which should be replaced with actual metadata.
                  minProperties: 0
                  default: {} 
                  example: { "key1": "value1", "key2": "value2" }
                description:
                  type: string
                  description: Description of the booking, if any.
                  example: Discussion about AI integration
                status:
                  type: string
                  description: Status of the booking, always pending.
                  example: PENDING
      responses:
        "201":
          description: Successfully created booking.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Booking successfully created.
        "400":
          description: Invalid request parameters.
        "500":
          description: Internal server error.