@smartbear/mcp
Version:
MCP server for interacting SmartBear Products
104 lines (103 loc) • 4.34 kB
JavaScript
import { z } from "zod";
// Zod schemas for SwaggerHub Registry API validation
export const ApiSearchParamsSchema = z.object({
query: z
.string()
.optional()
.describe("Search query to filter APIs by name, description, or content"),
state: z
.enum(["ALL", "PUBLISHED", "UNPUBLISHED"])
.optional()
.describe("Filter APIs by publication state - ALL (default), PUBLISHED, or UNPUBLISHED"),
tag: z.string().optional().describe("Filter APIs by tag"),
offset: z
.number()
.min(0)
.optional()
.describe("Offset for pagination (0-based, default 0)"),
limit: z
.number()
.min(1)
.max(100)
.optional()
.describe("Number of results per page (1-100, default 20)"),
sort: z
.enum(["NAME", "UPDATED", "CREATED"])
.optional()
.describe("Sort field - NAME, UPDATED, or CREATED (default NAME)"),
order: z
.enum(["ASC", "DESC"])
.optional()
.describe("Sort order - ASC or DESC (default ASC)"),
owner: z
.string()
.optional()
.describe("Filter APIs by owner (organization or user)"),
specType: z
.enum(["API", "DOMAIN"])
.optional()
.describe("Filter by specification type - API or DOMAIN (default all types)"),
});
export const ApiDefinitionParamsSchema = z.object({
owner: z
.string()
.describe("API owner (organization or user, case-sensitive)"),
api: z.string().describe("API name (case-sensitive)"),
version: z.string().describe("Version identifier"),
resolved: z
.boolean()
.optional()
.describe("Set to true to get the resolved version with all external $refs included (default false)"),
flatten: z
.boolean()
.optional()
.describe("Set to true to create models from inline schemas in OpenAPI definition (default false)"),
});
export const CreateApiParamsSchema = z.object({
owner: z.string().describe("Organization name (owner of the API)"),
apiName: z.string().describe("API name"),
definition: z
.string()
.describe("API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format). Format is automatically detected. API is created with fixed values: version 1.0.0, private visibility, automock disabled, and no project assignment."),
});
export const CreateApiFromTemplateParamsSchema = z.object({
owner: z.string().describe("Organization name (owner of the API)"),
apiName: z.string().describe("API name"),
template: z
.string()
.describe("Template name to use for creating the API. Format: owner/template-name/version (e.g., 'swagger-hub/petstore-template/1.0.0'). API is created with fixed values: private visibility, no project assignment, and reconciliation enabled."),
});
export const ScanStandardizationParamsSchema = z.object({
orgName: z
.string()
.describe("The organization name to use for standardization rules"),
definition: z
.string()
.describe("API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format) to scan for standardization errors"),
});
export const CreateApiFromPromptParamsSchema = z.object({
owner: z
.string()
.describe("API owner (organization or user, case-sensitive)"),
apiName: z.string().describe("API name"),
prompt: z
.string()
.describe("The prompt describing the desired API functionality (e.g., 'Create a RESTful API for managing a pet store with endpoints for pets, orders, and inventory')"),
specType: z
.enum([
"openapi20",
"openapi30x",
"openapi31x",
"asyncapi2xx",
"asyncapi30x",
])
.default("openapi30x")
.describe("Specification type for the generated API definition. Use: 'openapi20' for OpenAPI 2.0, 'openapi30x' for OpenAPI 3.0.x (default), 'openapi31x' for OpenAPI 3.1.x, 'asyncapi2xx' for AsyncAPI 2.x, 'asyncapi30x' for AsyncAPI 3.0.x"),
});
export const StandardizeApiParamsSchema = z.object({
owner: z
.string()
.describe("API owner (organization or user, case-sensitive)"),
api: z.string().describe("API name (case-sensitive)"),
version: z.string().describe("Version identifier"),
});