Тесты: часть 1

This commit is contained in:
2025-10-28 09:58:44 +03:00
parent 21c7ddfd54
commit 6bffe6a9e1
21 changed files with 2843 additions and 3 deletions

317
tests/fixtures/complex.json vendored Normal file
View File

@@ -0,0 +1,317 @@
{
"openapi": "3.0.0",
"info": {
"title": "Complex API",
"version": "1.0.0",
"description": "Большая спецификация для тестирования производительности"
},
"servers": [
{
"url": "https://api.example.com"
}
],
"paths": {
"/products": {
"get": {
"operationId": "ProductController_list",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
}
},
"post": {
"operationId": "ProductController_create",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateProduct"
}
}
}
},
"responses": {
"201": {
"description": "Created"
}
}
}
},
"/products/{id}": {
"get": {
"operationId": "ProductController_getById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
},
"put": {
"operationId": "ProductController_update",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
},
"delete": {
"operationId": "ProductController_delete",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "Deleted"
}
}
}
},
"/categories": {
"get": {
"operationId": "CategoryController_list",
"responses": {
"200": {
"description": "OK"
}
}
},
"post": {
"operationId": "CategoryController_create",
"responses": {
"201": {
"description": "Created"
}
}
}
},
"/categories/{id}": {
"get": {
"operationId": "CategoryController_getById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/orders": {
"get": {
"operationId": "OrderController_list",
"responses": {
"200": {
"description": "OK"
}
}
},
"post": {
"operationId": "OrderController_create",
"responses": {
"201": {
"description": "Created"
}
}
}
},
"/orders/{id}": {
"get": {
"operationId": "OrderController_getById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/customers": {
"get": {
"operationId": "CustomerController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/payments": {
"get": {
"operationId": "PaymentController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/invoices": {
"get": {
"operationId": "InvoiceController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/shipping": {
"get": {
"operationId": "ShippingController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/reports": {
"get": {
"operationId": "ReportController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/analytics": {
"get": {
"operationId": "AnalyticsController_getData",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/settings": {
"get": {
"operationId": "SettingsController_get",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/notifications": {
"get": {
"operationId": "NotificationController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/webhooks": {
"get": {
"operationId": "WebhookController_list",
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
"schemas": {
"Product": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"price": {
"type": "number"
},
"category": {
"$ref": "#/components/schemas/Category"
}
}
},
"CreateProduct": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"price": {
"type": "number"
}
}
},
"Category": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
}
}
}

67
tests/fixtures/edge-cases.json vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"openapi": "3.0.0",
"info": {
"title": "Edge Cases API",
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.example.com"
}
],
"paths": {
"/test-unicode-метод": {
"get": {
"operationId": "TestController_unicodeМетод",
"summary": "Тест с Unicode символами",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/test/special-chars/@{id}": {
"get": {
"operationId": "TestController_specialChars",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/test/very-long-endpoint-name-that-exceeds-normal-length-and-tests-edge-case": {
"get": {
"operationId": "TestController_veryLongEndpointNameThatExceedsNormalLengthAndTestsEdgeCase",
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
"schemas": {
"ВажныйТип": {
"type": "object",
"properties": {
"название": {
"type": "string"
}
}
}
}
}
}

8
tests/fixtures/empty.json vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"openapi": "3.0.0",
"info": {
"title": "Empty API",
"version": "1.0.0"
},
"paths": {}
}

10
tests/fixtures/invalid.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
"openapi": "3.0.0",
"paths": {
"/test": {
"get": {
"responses": {}
}
}
}
}

31
tests/fixtures/minimal.json vendored Normal file
View File

@@ -0,0 +1,31 @@
{
"openapi": "3.0.0",
"info": {
"title": "Minimal API",
"version": "1.0.0"
},
"paths": {
"/hello": {
"get": {
"operationId": "getHello",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}

228
tests/fixtures/valid.json vendored Normal file
View File

@@ -0,0 +1,228 @@
{
"openapi": "3.0.0",
"info": {
"title": "Test API",
"version": "1.0.0",
"description": "API для тестирования генератора"
},
"servers": [
{
"url": "https://api.example.com"
}
],
"paths": {
"/users": {
"get": {
"operationId": "UserController_getAll",
"summary": "Получить всех пользователей",
"parameters": [
{
"name": "page",
"in": "query",
"schema": {
"type": "integer",
"default": 1
}
},
{
"name": "limit",
"in": "query",
"schema": {
"type": "integer",
"default": 10
}
}
],
"responses": {
"200": {
"description": "Список пользователей",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
},
"post": {
"operationId": "UserController_create",
"summary": "Создать пользователя",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUserDto"
}
}
}
},
"responses": {
"201": {
"description": "Пользователь создан",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"400": {
"description": "Ошибка валидации"
}
}
}
},
"/users/{id}": {
"get": {
"operationId": "UserController_getById",
"summary": "Получить пользователя по ID",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Пользователь найден",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"404": {
"description": "Пользователь не найден"
}
}
},
"patch": {
"operationId": "UserController_update",
"summary": "Обновить пользователя",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateUserDto"
}
}
}
},
"responses": {
"200": {
"description": "Пользователь обновлен",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
},
"delete": {
"operationId": "UserController_delete",
"summary": "Удалить пользователя",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "Пользователь удален"
}
}
}
}
},
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "123"
},
"email": {
"type": "string",
"example": "user@example.com"
},
"name": {
"type": "string",
"example": "John Doe"
},
"role": {
"$ref": "#/components/schemas/UserRole"
},
"createdAt": {
"type": "string",
"format": "date-time"
}
},
"required": ["id", "email", "role"]
},
"CreateUserDto": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"name": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": ["email", "password"]
},
"UpdateUserDto": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
}
}
},
"UserRole": {
"type": "string",
"enum": ["admin", "user", "guest"]
}
}
}
}

102
tests/fixtures/with-auth.json vendored Normal file
View File

@@ -0,0 +1,102 @@
{
"openapi": "3.0.0",
"info": {
"title": "Auth API",
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.example.com"
}
],
"paths": {
"/auth/login": {
"post": {
"operationId": "AuthController_login",
"summary": "Войти в систему",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": ["email", "password"]
}
}
}
},
"responses": {
"200": {
"description": "Успешная авторизация",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
}
}
}
},
"401": {
"description": "Неверные учетные данные"
}
}
}
},
"/profile": {
"get": {
"operationId": "ProfileController_get",
"summary": "Получить профиль",
"security": [
{
"bearer": []
}
],
"responses": {
"200": {
"description": "Профиль пользователя",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"email": {
"type": "string"
}
}
}
}
}
},
"401": {
"description": "Не авторизован"
}
}
}
}
},
"components": {
"securitySchemes": {
"bearer": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
}
}