#1426·mockoon

Feature Request: Support for Data Contract Definition in Mockoon

Author: mourad-ghafiriCreated Jun 19, 2024Updated Jun 3, 2026
Labelscomponent:appstatus:need-more-interest

Summary: Mockoon currently supports the OpenAPI specification for defining API endpoint contracts. However, OpenAPI also allows for defining data contracts (schemas) which are essential for ensuring data integrity and consistency across different parts of an API. This feature request is to enhance Mockoon to support data contract definitions alongside endpoint contracts.

Background: OpenAPI Specification provides a comprehensive framework for defining both API endpoints and data contracts. While Mockoon excels at creating mock servers and simulating endpoint responses, the ability to define and validate data contracts (schemas) would significantly enhance its utility for developers who rely on these definitions to maintain consistency in their APIs.

Proposed Solution:

  1. Schema Definition Support:

    • Extend Mockoon to support the components.schemas section of the OpenAPI Specification.
    • Allow users to define reusable data schemas that can be referenced in endpoint definitions.
  2. Schema Validation:

    • Implement validation mechanisms to ensure that the data returned by mock endpoints conforms to the defined schemas.
    • Provide feedback to users if the mock data does not comply with the specified data contract.
  3. User Interface Enhancements:

    • Update the Mockoon UI to allow easy creation and management of data schemas.
    • Provide a visual representation of the data contracts similar to how endpoint contracts are displayed.

Benefits:

  • Data Consistency: Ensures that the data structure remains consistent across different endpoints and services.
  • Improved Mocking Accuracy: Enhances the realism and accuracy of the mock data by adhering to defined schemas.
  • Developer Productivity: Simplifies the development process by allowing developers to define and test data contracts within the same tool.

Example: A sample OpenAPI definition with data contract support:

yaml
openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /user:
    get:
      summary: Get user
      responses:
        '200':
          description: A user object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        email:
          type: string