Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:52:26 +08:00
commit cd85d9d995
16 changed files with 2047 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
# openapi_example.yaml
# This file defines an example OpenAPI specification for the API Mock Server plugin.
# It's designed to be a starting point and should be customized to your specific API.
openapi: 3.0.0
info:
title: Example API
version: 1.0.0
description: A simple example API for demonstration purposes.
servers:
- url: http://localhost:8080 # The base URL where the mock server will run. Change if needed.
description: Local development server
paths:
/users:
get:
summary: Get a list of users
description: Returns a list of all users.
operationId: getUsers
responses:
'200':
description: A list of users.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
'500':
description: Internal server error. Simulates a possible error response.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error message.
example: "Internal Server Error"
post:
summary: Create a new user
description: Creates a new user.
operationId: createUser
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserCreate'
responses:
'201':
description: User created successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'400':
description: Bad request. Invalid input.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error message.
example: "Invalid input data"
/users/{userId}:
get:
summary: Get a user by ID
description: Returns a single 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: The user object.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'404':
description: User not found.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error message.
example: "User not found"
components:
schemas:
User:
type: object
properties:
id:
type: integer
description: The user's ID.
example: 123
name:
type: string
description: The user's name.
example: "John Doe"
email:
type: string
format: email
description: The user's email address.
example: "john.doe@example.com"
# Add more user properties as needed
# Example:
# role:
# type: string
# description: The user's role.
# example: "admin"
required:
- id
- name
- email
UserCreate:
type: object
properties:
name:
type: string
description: The user's name.
example: "Jane Doe"
email:
type: string
format: email
description: The user's email address.
example: "jane.doe@example.com"
# Add more user creation properties as needed
required:
- name
- email