# OpenAPI Specification Example for Contract Test Validator Plugin # This file defines the structure of an example API for testing purposes. openapi: 3.0.0 info: title: Example API for Contract Testing version: 1.0.0 description: A simple API to demonstrate contract testing with Pact and OpenAPI validation. contact: name: REPLACE_ME - Your Name email: REPLACE_ME - your.email@example.com servers: - url: https://api.example.com/v1 description: Production server paths: /users: get: summary: Get all users description: Retrieves a list of all users. operationId: getUsers responses: '200': description: Successful operation content: application/json: schema: type: array items: $ref: '#/components/schemas/User' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/Error' post: summary: Create a new user description: Creates a new user with the provided information. operationId: createUser requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateUserRequest' responses: '201': description: User created successfully content: application/json: schema: $ref: '#/components/schemas/User' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/Error' /users/{userId}: get: summary: Get user by ID description: Retrieves a specific user by their ID. operationId: getUserById parameters: - in: path name: userId schema: type: integer required: true description: The ID of the user to retrieve responses: '200': description: Successful operation content: application/json: schema: $ref: '#/components/schemas/User' '404': description: User not found content: application/json: schema: $ref: '#/components/schemas/Error' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/Error' put: summary: Update user by ID description: Updates a specific user by their ID. operationId: updateUserById parameters: - in: path name: userId schema: type: integer required: true description: The ID of the user to update requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateUserRequest' responses: '200': description: Successful operation content: application/json: schema: $ref: '#/components/schemas/User' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: User not found content: application/json: schema: $ref: '#/components/schemas/Error' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/Error' delete: summary: Delete user by ID description: Deletes a specific user by their ID. operationId: deleteUserById parameters: - in: path name: userId schema: type: integer required: true description: The ID of the user to delete responses: '204': description: User deleted successfully '404': description: User not found content: application/json: schema: $ref: '#/components/schemas/Error' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/Error' components: schemas: User: type: object properties: id: type: integer description: The user ID. name: type: string description: The user's name. email: type: string format: email description: The user's email address. created_at: type: string format: date-time description: The date and time the user was created. required: - id - name - email CreateUserRequest: type: object properties: name: type: string description: The user's name. email: type: string format: email description: The user's email address. required: - name - email UpdateUserRequest: type: object properties: name: type: string description: The user's name. email: type: string format: email description: The user's email address. Error: type: object properties: code: type: integer description: The error code. message: type: string description: The error message. required: - code - message securitySchemes: bearerAuth: # arbitrary name for the security scheme type: http scheme: bearer bearerFormat: JWT # optional, for documentation purposes only security: - bearerAuth: [] # applies the "bearerAuth" security scheme to all operations