mirror of
https://github.com/LukeHagar/varsity.git
synced 2025-12-06 04:22:00 +00:00
Initial commit
This commit is contained in:
53
test/backwards-refs/main-api.json
Normal file
53
test/backwards-refs/main-api.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Backwards References API",
|
||||
"version": "1.0.0",
|
||||
"description": "API with backwards $ref paths for testing"
|
||||
},
|
||||
"paths": {
|
||||
"/users": {
|
||||
"get": {
|
||||
"summary": "Get users",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "../shared/responses/users-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/products": {
|
||||
"get": {
|
||||
"summary": "Get products",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "../shared/responses/products-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/orders": {
|
||||
"get": {
|
||||
"summary": "Get orders",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "../shared/responses/orders-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"User": {
|
||||
"$ref": "../shared/schemas/user-schema.json"
|
||||
},
|
||||
"Product": {
|
||||
"$ref": "../shared/schemas/product-schema.json"
|
||||
},
|
||||
"Order": {
|
||||
"$ref": "../shared/schemas/order-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
145
test/basic.test.ts
Normal file
145
test/basic.test.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import {
|
||||
validate,
|
||||
parse,
|
||||
generateValidationReport,
|
||||
getSupportedVersions,
|
||||
createVarsity,
|
||||
type ValidationResult,
|
||||
} from "../src/varsity.js";
|
||||
import { resolve } from "path";
|
||||
|
||||
describe("Varsity Library", () => {
|
||||
const sampleSpecPath = resolve(__dirname, "sample-openapi.json");
|
||||
|
||||
test("should parse a valid OpenAPI specification", async () => {
|
||||
const parsed = await parse(sampleSpecPath);
|
||||
|
||||
expect(parsed).toBeDefined();
|
||||
expect(parsed.version).toBe("3.0.3");
|
||||
expect(parsed.spec.info.title).toBe("Sample API");
|
||||
});
|
||||
|
||||
test("should validate a valid OpenAPI specification", async () => {
|
||||
const result = (await validate(sampleSpecPath)) as ValidationResult;
|
||||
|
||||
expect(result.valid).toBe(true);
|
||||
expect(result.errors).toHaveLength(0);
|
||||
expect(result.version).toBe("3.0.3");
|
||||
});
|
||||
|
||||
test("should generate a JSON report", async () => {
|
||||
const report = await generateValidationReport(sampleSpecPath, {
|
||||
format: "json",
|
||||
includeWarnings: true,
|
||||
includeMetadata: true,
|
||||
});
|
||||
|
||||
const parsedReport = JSON.parse(report);
|
||||
expect(parsedReport.summary.valid).toBe(true);
|
||||
expect(parsedReport.summary.version).toBe("3.0.3");
|
||||
});
|
||||
|
||||
test("should generate a markdown report", async () => {
|
||||
const report = await generateValidationReport(sampleSpecPath, {
|
||||
format: "markdown",
|
||||
includeWarnings: true,
|
||||
includeMetadata: true,
|
||||
});
|
||||
|
||||
expect(report).toContain("# OpenAPI Validation Report");
|
||||
expect(report).toContain("✅ Valid");
|
||||
expect(report).toContain("Sample API");
|
||||
});
|
||||
|
||||
test("should get supported versions", () => {
|
||||
const versions = getSupportedVersions();
|
||||
|
||||
expect(versions).toContain("2.0");
|
||||
expect(versions).toContain("3.0.3");
|
||||
expect(versions).toContain("3.1.0");
|
||||
});
|
||||
|
||||
test("should handle invalid specification", async () => {
|
||||
const invalidSpec = {
|
||||
openapi: "3.0.3",
|
||||
// Missing required 'info' and 'paths' fields
|
||||
};
|
||||
|
||||
// Create a temporary file with invalid spec
|
||||
const fs = await import("fs");
|
||||
const tempPath = resolve(__dirname, "invalid-spec.json");
|
||||
fs.writeFileSync(tempPath, JSON.stringify(invalidSpec));
|
||||
|
||||
try {
|
||||
const result = (await validate(tempPath)) as ValidationResult;
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.errors.length).toBeGreaterThan(0);
|
||||
} finally {
|
||||
// Clean up
|
||||
fs.unlinkSync(tempPath);
|
||||
}
|
||||
});
|
||||
|
||||
test("should work with createVarsity factory", async () => {
|
||||
const varsity = createVarsity();
|
||||
|
||||
const result = (await varsity.validate(sampleSpecPath)) as ValidationResult;
|
||||
expect(result.valid).toBe(true);
|
||||
|
||||
const versions = varsity.getSupportedVersions();
|
||||
expect(versions).toContain("3.0.3");
|
||||
});
|
||||
|
||||
test("should work with createVarsity factory for multiple specs", async () => {
|
||||
const varsity = createVarsity();
|
||||
|
||||
const results = (await varsity.validate([
|
||||
sampleSpecPath,
|
||||
sampleSpecPath,
|
||||
])) as ValidationResult[];
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
expect(results).toHaveLength(2);
|
||||
expect(results[0]?.valid).toBe(true);
|
||||
expect(results[1]?.valid).toBe(true);
|
||||
});
|
||||
|
||||
test("should validate multiple specifications", async () => {
|
||||
const results = (await validate([
|
||||
sampleSpecPath,
|
||||
sampleSpecPath,
|
||||
])) as ValidationResult[];
|
||||
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
expect(results).toHaveLength(2);
|
||||
expect(results[0]?.valid).toBe(true);
|
||||
expect(results[1]?.valid).toBe(true);
|
||||
});
|
||||
|
||||
test("should handle mixed valid and invalid specifications", async () => {
|
||||
const invalidSpec = {
|
||||
openapi: "3.0.3",
|
||||
// Missing required 'info' and 'paths' fields
|
||||
};
|
||||
|
||||
// Create a temporary file with invalid spec
|
||||
const fs = await import("fs");
|
||||
const tempPath = resolve(__dirname, "invalid-spec-mixed.json");
|
||||
fs.writeFileSync(tempPath, JSON.stringify(invalidSpec));
|
||||
|
||||
try {
|
||||
const results = (await validate([
|
||||
sampleSpecPath,
|
||||
tempPath,
|
||||
])) as ValidationResult[];
|
||||
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
expect(results).toHaveLength(2);
|
||||
expect(results[0]?.valid).toBe(true); // Valid spec
|
||||
expect(results[1]?.valid).toBe(false); // Invalid spec
|
||||
} finally {
|
||||
// Clean up
|
||||
fs.unlinkSync(tempPath);
|
||||
}
|
||||
});
|
||||
});
|
||||
30
test/circular-refs-api.json
Normal file
30
test/circular-refs-api.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Circular References API",
|
||||
"version": "1.0.0",
|
||||
"description": "API with intentional circular references for testing"
|
||||
},
|
||||
"paths": {
|
||||
"/users": {
|
||||
"get": {
|
||||
"summary": "Get users",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "./responses/users-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"User": {
|
||||
"$ref": "./schemas/user-schema.json"
|
||||
},
|
||||
"Category": {
|
||||
"$ref": "./schemas/category-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
test/deep/nested/api/main-api.json
Normal file
40
test/deep/nested/api/main-api.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Deep Nested API with Backwards References",
|
||||
"version": "1.0.0",
|
||||
"description": "API in deep nested directory with backwards $ref paths"
|
||||
},
|
||||
"paths": {
|
||||
"/users": {
|
||||
"get": {
|
||||
"summary": "Get users",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "../../../shared/responses/users-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/products": {
|
||||
"get": {
|
||||
"summary": "Get products",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "../../../shared/responses/products-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"User": {
|
||||
"$ref": "../../../shared/schemas/user-schema.json"
|
||||
},
|
||||
"Product": {
|
||||
"$ref": "../../../shared/schemas/product-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
test/edge-cases/very-deep/api/main-api.json
Normal file
27
test/edge-cases/very-deep/api/main-api.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Edge Cases API",
|
||||
"version": "1.0.0",
|
||||
"description": "API testing various edge cases for $ref resolution"
|
||||
},
|
||||
"paths": {
|
||||
"/test": {
|
||||
"get": {
|
||||
"summary": "Test endpoint",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "../../../../shared/responses/test-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestSchema": {
|
||||
"$ref": "../../../../shared/schemas/test-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
108
test/main-api.json
Normal file
108
test/main-api.json
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Main API",
|
||||
"version": "1.0.0",
|
||||
"description": "Main API with external references"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://api.example.com/v1"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/users": {
|
||||
"get": {
|
||||
"summary": "Get all users",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "./responses/users-response.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Create user",
|
||||
"requestBody": {
|
||||
"$ref": "./request-bodies/user-request.json"
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"$ref": "./responses/user-created-response.json"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "./responses/error-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}": {
|
||||
"get": {
|
||||
"summary": "Get user by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "./parameters/user-id-param.json"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "./responses/user-response.json"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "./responses/not-found-response.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"summary": "Update user",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "./parameters/user-id-param.json"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "./request-bodies/user-update-request.json"
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "./responses/user-response.json"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "./responses/error-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/products": {
|
||||
"$ref": "./paths/products-path.json"
|
||||
},
|
||||
"/orders": {
|
||||
"$ref": "./paths/orders-path.json"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"User": {
|
||||
"$ref": "./schemas/user-schema.json"
|
||||
},
|
||||
"Product": {
|
||||
"$ref": "./schemas/product-schema.json"
|
||||
},
|
||||
"Error": {
|
||||
"$ref": "./schemas/error-schema.json"
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"PageParam": {
|
||||
"$ref": "./parameters/page-param.json"
|
||||
},
|
||||
"LimitParam": {
|
||||
"$ref": "./parameters/limit-param.json"
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"UnauthorizedResponse": {
|
||||
"$ref": "./responses/unauthorized-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
test/parameters/category-filter-param.json
Normal file
10
test/parameters/category-filter-param.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "category",
|
||||
"in": "query",
|
||||
"description": "Filter products by category",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
12
test/parameters/limit-param.json
Normal file
12
test/parameters/limit-param.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
"description": "Number of items per page",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 100,
|
||||
"default": 20
|
||||
}
|
||||
}
|
||||
10
test/parameters/order-id-param.json
Normal file
10
test/parameters/order-id-param.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "Order ID",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"pattern": "^ORD-[0-9]{8}$"
|
||||
}
|
||||
}
|
||||
11
test/parameters/page-param.json
Normal file
11
test/parameters/page-param.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "page",
|
||||
"in": "query",
|
||||
"description": "Page number for pagination",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"default": 1
|
||||
}
|
||||
}
|
||||
10
test/parameters/status-filter-param.json
Normal file
10
test/parameters/status-filter-param.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "status",
|
||||
"in": "query",
|
||||
"description": "Filter orders by status",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["pending", "processing", "shipped", "delivered", "cancelled"]
|
||||
}
|
||||
}
|
||||
11
test/parameters/user-id-param.json
Normal file
11
test/parameters/user-id-param.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "User ID",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
74
test/paths/orders-path.json
Normal file
74
test/paths/orders-path.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"get": {
|
||||
"summary": "Get all orders",
|
||||
"description": "Retrieve orders for the authenticated user",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "../parameters/page-param.json"
|
||||
},
|
||||
{
|
||||
"$ref": "../parameters/limit-param.json"
|
||||
},
|
||||
{
|
||||
"$ref": "../parameters/status-filter-param.json"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "List of orders",
|
||||
"$ref": "../responses/orders-response.json"
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"$ref": "../responses/unauthorized-response.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Create a new order",
|
||||
"description": "Place a new order",
|
||||
"requestBody": {
|
||||
"$ref": "../request-bodies/order-request.json"
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Order created successfully",
|
||||
"$ref": "../responses/order-created-response.json"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"$ref": "../responses/error-response.json"
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"$ref": "../responses/unauthorized-response.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"summary": "Update order status",
|
||||
"description": "Update the status of an existing order",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "../parameters/order-id-param.json"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "../request-bodies/order-status-update.json"
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Order updated successfully",
|
||||
"$ref": "../responses/order-response.json"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"$ref": "../responses/error-response.json"
|
||||
},
|
||||
"404": {
|
||||
"description": "Order not found",
|
||||
"$ref": "../responses/not-found-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
48
test/paths/products-path.json
Normal file
48
test/paths/products-path.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"get": {
|
||||
"summary": "Get all products",
|
||||
"description": "Retrieve a paginated list of products with optional filtering",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "../parameters/page-param.json"
|
||||
},
|
||||
{
|
||||
"$ref": "../parameters/limit-param.json"
|
||||
},
|
||||
{
|
||||
"$ref": "../parameters/category-filter-param.json"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "List of products",
|
||||
"$ref": "../responses/products-response.json"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"$ref": "../responses/error-response.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Create a new product",
|
||||
"description": "Add a new product to the catalog",
|
||||
"requestBody": {
|
||||
"$ref": "../request-bodies/product-request.json"
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Product created successfully",
|
||||
"$ref": "../responses/product-created-response.json"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"$ref": "../responses/error-response.json"
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"$ref": "../responses/unauthorized-response.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
test/request-bodies/order-request.json
Normal file
34
test/request-bodies/order-request.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"description": "Order creation data",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["items", "shippingAddress"],
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/order-item-schema.json"
|
||||
},
|
||||
"minItems": 1
|
||||
},
|
||||
"shippingAddress": {
|
||||
"$ref": "../schemas/address-schema.json"
|
||||
},
|
||||
"billingAddress": {
|
||||
"$ref": "../schemas/address-schema.json"
|
||||
},
|
||||
"paymentMethod": {
|
||||
"$ref": "../schemas/payment-method-schema.json"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 500
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
test/request-bodies/order-status-update.json
Normal file
32
test/request-bodies/order-status-update.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"description": "Order status update data",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["status"],
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"pending",
|
||||
"processing",
|
||||
"shipped",
|
||||
"delivered",
|
||||
"cancelled"
|
||||
]
|
||||
},
|
||||
"trackingNumber": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Z0-9]{10,20}$"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 500
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
test/request-bodies/product-request.json
Normal file
38
test/request-bodies/product-request.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"description": "Product creation data",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["name", "price"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 200
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"price": {
|
||||
"$ref": "../schemas/price-schema.json"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "../schemas/category-schema.json"
|
||||
},
|
||||
"inventory": {
|
||||
"$ref": "../schemas/inventory-schema.json"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
test/request-bodies/user-request.json
Normal file
34
test/request-bodies/user-request.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"description": "User creation data",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["name", "email"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email"
|
||||
},
|
||||
"age": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 150
|
||||
},
|
||||
"address": {
|
||||
"$ref": "../schemas/address-schema.json"
|
||||
},
|
||||
"preferences": {
|
||||
"$ref": "../schemas/user-preferences-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
test/request-bodies/user-update-request.json
Normal file
33
test/request-bodies/user-update-request.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"description": "User update data",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email"
|
||||
},
|
||||
"age": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 150
|
||||
},
|
||||
"address": {
|
||||
"$ref": "../schemas/address-schema.json"
|
||||
},
|
||||
"preferences": {
|
||||
"$ref": "../schemas/user-preferences-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
test/responses/error-response.json
Normal file
10
test/responses/error-response.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"description": "Bad request error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "../schemas/error-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
test/responses/not-found-response.json
Normal file
10
test/responses/not-found-response.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"description": "Resource not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "../schemas/error-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/responses/order-created-response.json
Normal file
18
test/responses/order-created-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "Order created successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "../schemas/order-schema.json"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/responses/order-response.json
Normal file
15
test/responses/order-response.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"description": "Order details",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "../schemas/order-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
test/responses/orders-response.json
Normal file
21
test/responses/orders-response.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"description": "List of orders",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/order-schema.json"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "../schemas/pagination-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/responses/product-created-response.json
Normal file
18
test/responses/product-created-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "Product created successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "../schemas/product-schema.json"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
test/responses/products-response.json
Normal file
21
test/responses/products-response.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"description": "List of products",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/product-schema.json"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "../schemas/pagination-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
test/responses/unauthorized-response.json
Normal file
10
test/responses/unauthorized-response.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"description": "Unauthorized access",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "../schemas/error-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/responses/user-created-response.json
Normal file
18
test/responses/user-created-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "User created successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "../schemas/user-schema.json"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/responses/user-response.json
Normal file
15
test/responses/user-response.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"description": "User details",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "../schemas/user-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/responses/users-response.json
Normal file
18
test/responses/users-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "List of users",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/user-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
test/sample-openapi.json
Normal file
43
test/sample-openapi.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "Sample API",
|
||||
"version": "1.0.0",
|
||||
"description": "A sample OpenAPI specification for testing"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://api.example.com/v1"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/users": {
|
||||
"get": {
|
||||
"summary": "Get all users",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
test/schemas/address-schema.json
Normal file
28
test/schemas/address-schema.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"street": {
|
||||
"type": "string",
|
||||
"description": "Street address"
|
||||
},
|
||||
"city": {
|
||||
"type": "string",
|
||||
"description": "City name"
|
||||
},
|
||||
"state": {
|
||||
"type": "string",
|
||||
"description": "State or province"
|
||||
},
|
||||
"zipCode": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{5}(-[0-9]{4})?$",
|
||||
"description": "ZIP or postal code"
|
||||
},
|
||||
"country": {
|
||||
"type": "string",
|
||||
"minLength": 2,
|
||||
"maxLength": 2,
|
||||
"description": "Two-letter country code"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
test/schemas/category-schema.json
Normal file
21
test/schemas/category-schema.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"parent": {
|
||||
"$ref": "./category-schema.json"
|
||||
},
|
||||
"children": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "./category-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
test/schemas/error-schema.json
Normal file
19
test/schemas/error-schema.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["code", "message"],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"details": {
|
||||
"type": "string"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
}
|
||||
20
test/schemas/inventory-schema.json
Normal file
20
test/schemas/inventory-schema.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"reserved": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"available": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"warehouse": {
|
||||
"$ref": "./warehouse-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
23
test/schemas/order-item-schema.json
Normal file
23
test/schemas/order-item-schema.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["productId", "quantity"],
|
||||
"properties": {
|
||||
"productId": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"minimum": 1
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"price": {
|
||||
"$ref": "./price-schema.json"
|
||||
},
|
||||
"discount": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
44
test/schemas/order-schema.json
Normal file
44
test/schemas/order-schema.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "status", "items", "total"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^ORD-[0-9]{8}$"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["pending", "processing", "shipped", "delivered", "cancelled"]
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "./order-item-schema.json"
|
||||
}
|
||||
},
|
||||
"total": {
|
||||
"$ref": "./price-schema.json"
|
||||
},
|
||||
"shippingAddress": {
|
||||
"$ref": "./address-schema.json"
|
||||
},
|
||||
"billingAddress": {
|
||||
"$ref": "./address-schema.json"
|
||||
},
|
||||
"paymentMethod": {
|
||||
"$ref": "./payment-method-schema.json"
|
||||
},
|
||||
"trackingNumber": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Z0-9]{10,20}$"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
}
|
||||
28
test/schemas/pagination-schema.json
Normal file
28
test/schemas/pagination-schema.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"page": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"limit": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 100
|
||||
},
|
||||
"total": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"totalPages": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"hasNext": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasPrev": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
35
test/schemas/payment-method-schema.json
Normal file
35
test/schemas/payment-method-schema.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["type", "details"],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["credit_card", "debit_card", "paypal", "bank_transfer"]
|
||||
},
|
||||
"details": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cardNumber": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{13,19}$"
|
||||
},
|
||||
"expiryMonth": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 12
|
||||
},
|
||||
"expiryYear": {
|
||||
"type": "integer",
|
||||
"minimum": 2024
|
||||
},
|
||||
"cvv": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{3,4}$"
|
||||
},
|
||||
"accountId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
test/schemas/price-schema.json
Normal file
30
test/schemas/price-schema.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["amount", "currency"],
|
||||
"properties": {
|
||||
"amount": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"multipleOf": 0.01
|
||||
},
|
||||
"currency": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Z]{3}$",
|
||||
"description": "ISO 4217 currency code"
|
||||
},
|
||||
"discount": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"percentage": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 100
|
||||
},
|
||||
"validUntil": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/schemas/privacy-settings-schema.json
Normal file
18
test/schemas/privacy-settings-schema.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"profileVisibility": {
|
||||
"type": "string",
|
||||
"enum": ["public", "private", "friends"],
|
||||
"default": "private"
|
||||
},
|
||||
"dataSharing": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"analytics": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
}
|
||||
34
test/schemas/product-schema.json
Normal file
34
test/schemas/product-schema.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name", "price"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 200
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"price": {
|
||||
"$ref": "./price-schema.json"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "./category-schema.json"
|
||||
},
|
||||
"inventory": {
|
||||
"$ref": "./inventory-schema.json"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
test/schemas/user-preferences-schema.json
Normal file
37
test/schemas/user-preferences-schema.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"theme": {
|
||||
"type": "string",
|
||||
"enum": ["light", "dark", "auto"],
|
||||
"default": "auto",
|
||||
"description": "User's preferred theme"
|
||||
},
|
||||
"language": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z]{2}(-[A-Z]{2})?$",
|
||||
"default": "en",
|
||||
"description": "User's preferred language code"
|
||||
},
|
||||
"notifications": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"push": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"sms": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"privacy": {
|
||||
"$ref": "./privacy-settings-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
44
test/schemas/user-schema.json
Normal file
44
test/schemas/user-schema.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name", "email"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Unique identifier for the user"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"description": "User's full name"
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"description": "User's email address"
|
||||
},
|
||||
"age": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 150,
|
||||
"description": "User's age"
|
||||
},
|
||||
"address": {
|
||||
"$ref": "./address-schema.json"
|
||||
},
|
||||
"preferences": {
|
||||
"$ref": "./user-preferences-schema.json"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "When the user was created"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "When the user was last updated"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/schemas/warehouse-schema.json
Normal file
15
test/schemas/warehouse-schema.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "./address-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/shared/responses/orders-response.json
Normal file
18
test/shared/responses/orders-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "List of orders",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/order-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/shared/responses/products-response.json
Normal file
18
test/shared/responses/products-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "List of products",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/product-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/shared/responses/test-response.json
Normal file
15
test/shared/responses/test-response.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"description": "Test response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/shared/responses/users-response.json
Normal file
18
test/shared/responses/users-response.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "List of users",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "../schemas/user-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
test/shared/schemas/address-schema.json
Normal file
23
test/shared/schemas/address-schema.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"street": {
|
||||
"type": "string"
|
||||
},
|
||||
"city": {
|
||||
"type": "string"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"zipCode": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{5}(-[0-9]{4})?$"
|
||||
},
|
||||
"country": {
|
||||
"type": "string",
|
||||
"minLength": 2,
|
||||
"maxLength": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/shared/schemas/category-schema.json
Normal file
15
test/shared/schemas/category-schema.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
test/shared/schemas/order-item-schema.json
Normal file
18
test/shared/schemas/order-item-schema.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["productId", "quantity"],
|
||||
"properties": {
|
||||
"productId": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"minimum": 1
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"price": {
|
||||
"$ref": "./price-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
23
test/shared/schemas/order-schema.json
Normal file
23
test/shared/schemas/order-schema.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "status", "items"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^ORD-[0-9]{8}$"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["pending", "processing", "shipped", "delivered", "cancelled"]
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "./order-item-schema.json"
|
||||
}
|
||||
},
|
||||
"total": {
|
||||
"$ref": "./price-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/shared/schemas/price-schema.json
Normal file
15
test/shared/schemas/price-schema.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["amount", "currency"],
|
||||
"properties": {
|
||||
"amount": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"multipleOf": 0.01
|
||||
},
|
||||
"currency": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Z]{3}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
test/shared/schemas/product-schema.json
Normal file
21
test/shared/schemas/product-schema.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name", "price"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 200
|
||||
},
|
||||
"price": {
|
||||
"$ref": "./price-schema.json"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "./category-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
test/shared/schemas/test-schema.json
Normal file
15
test/shared/schemas/test-schema.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
test/shared/schemas/user-schema.json
Normal file
22
test/shared/schemas/user-schema.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["id", "name", "email"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email"
|
||||
},
|
||||
"address": {
|
||||
"$ref": "./address-schema.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user