Feature Request: Support for Data Contract Definition in Mockoon
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:
Schema Definition Support:
- Extend Mockoon to support the
components.schemassection of the OpenAPI Specification. - Allow users to define reusable data schemas that can be referenced in endpoint definitions.
- Extend Mockoon to support the
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.
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:
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: stringSource: mockoon/mockoon