Swagger Studio Integration
The Swagger Studio client provides comprehensive API and Domain management capabilities through SwaggerHub Registry. Access to these features requires authentication with a SWAGGER_API_KEY.
Available Tools
Swagger Studio API Tools
search_apis_and_domains
- Purpose: Search for APIs and Domains in Swagger Studio using the comprehensive /specs endpoint and retrieve metadata including owner, name, description, summary, version, and specification.
- Returns: List of API and Domain specifications matching the search criteria.
- Use case: Discover existing APIs and domains for integration or reference.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
query | Free text search - searches name and description | string | No |
owner | API/Domain owner (username or organization name) | string | No |
sort | Field used to sort the list. Options: NAME, UPDATED, CREATED, OWNERDefault: NAME | string | No |
order | Sort order. Options: ASC, DESCDefault: ASC | string | No |
page | Page to return Default: 0 | number | No |
limit | Number of results per page Default: 10, Max: 100 | number | No |
specType | Type of spec to search for. Options: API, DOMAIN, ANYDefault: ANY | string | No |
visibility | Visibility of the spec. Options: PUBLIC, PRIVATE, ANYDefault: ANY | string | No |
state | State of the spec. Options: PUBLISHED, UNPUBLISHED, ANYDefault: ANY | string | No |
get_api_definition
- Purpose: Fetch an API definition from Swagger Studio based on its owner, API name, and version. By default the definition is returned as JSON (YAML-stored definitions are converted); set
format: 'text'to get the YAML source. - Returns: Complete OpenAPI specification for the requested API, as JSON or as YAML text depending on
format. - Use case: Retrieve the specified API definitions for integration, testing, or documentation purposes, or fetch the YAML source with
format: 'text'to use as the base forpatch_apiedits. - Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
owner | API owner (organization or user, case-sensitive) | string | Yes |
api | API name (case-sensitive) | string | Yes |
version | Version identifier | string | Yes |
resolved | Set to true to get the resolved version with all external $refs included.Default: false | boolean | No |
flatten | Set to true to create models from inline schemas in an OpenAPI definition. Default: false | boolean | No |
format | Response format. Options: json (may convert YAML to JSON), text (returns the definition as YAML - required for patch_api edits)Default: json | string | No |
create_or_update_api
- Purpose: Create a new API or update an existing API in SwaggerHub Registry for Swagger Studio. The API specification type (OpenAPI, AsyncAPI) is automatically detected from the definition content. If an API with the same owner and name already exists, it will be updated; otherwise, a new API will be created.
- Returns: API metadata including owner, name, version, SwaggerHub URL, and operation type ('create' or 'update'). HTTP 201 indicates creation, HTTP 200 indicates update.
- Use case: Programmatically create new APIs from OpenAPI/AsyncAPI specifications, update existing API definitions with new versions of the specification, or migrate APIs into Swagger Studio.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
owner | Organization name (owner of the API) | string | Yes |
apiName | API name. If an API with this name already exists under the specified owner, it will be updated. | string | Yes |
definition | API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format). Format is automatically detected. On create, fixed values are used: version 1.0.0, private visibility, automock disabled, and no project assignment. On update, the API's existing visibility is preserved. | string | Yes |
scan_api_standardization
- Purpose: Run a standardization scan against an API definition using the organization's governance and standardization configuration. Validates OpenAPI/AsyncAPI definitions against configured rules and style guides.
- Returns: Standardization result with a list of validation errors, the total issue count, and counts grouped by severity (e.g.
count: 12,countsBySeverity: { "Critical": 5, "Warning": 7 }). Each error includes line number, description, and severity. - Use case: Validate API definitions against organization standards before publishing, ensure compliance with API governance policies, and identify design inconsistencies early in the development process.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
orgName | Organization name to use for governance and standardization rules | string | Yes |
definition | API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format). Format is automatically detected. | string | Yes |
scan_api_standardization_from_registry
- Purpose: Run a standardization scan on an API that already exists in the SwaggerHub Registry, identified by organization name, API name, and version. The tool fetches the API definition from the registry and scans it against the organization's governance and standardization rules internally.
- Returns: The standardization scan results together with the total issue count, counts grouped by severity (e.g.
count: 137,countsBySeverity: { "Critical": 92, "Warning": 45 }), and a SwaggerHub UI URL for the scanned API. Returns a clear error if the API is not found or the scan fails. - Use case: Validate, scan, or check the governance or standardization of an existing API by its owner/name/version without manually fetching and passing the definition first.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
orgName | Organization name. Used to fetch the API definition from the registry and to apply the organization's standardization rules (case-sensitive). | string | Yes |
apiName | API name (case-sensitive) | string | Yes |
version | Version identifier | string | Yes |
validate_api
- Purpose: Validate the structure of an OpenAPI (2.0, 3.0, 3.1) or AsyncAPI definition using server-side apidom-ls and asyncapi/parser, matching the Validation tab in Swagger Studio.
- Returns:
valid,recognized, the detectedspec(namespace, version, format), asummarywith error and warning counts, andfindingswith line, column, severity and message. A definition that is not recognized as a supported spec returnsrecognized: falseinstead of an error. - Use case: Check an API definition for structural errors before saving or publishing it.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
definition | API definition content (JSON or YAML). Provide this or owner/apiName/version, not both. | string | No |
owner | API owner, used with apiName and version to validate an existing API from the registry | string | No |
apiName | API name | string | No |
version | Version identifier | string | No |
maxProblems | Cap on the number of findings returned (default 100, max 1000). The summary still counts all problems. | number | No |
create_api_from_prompt
- Purpose: Generate and save a new API or a new version of an existing API from a natural language prompt using SmartBear AI, applying the organization's governance and standardization rules during generation. The specType parameter determines the format of the generated definition. Fails with a conflict error if the API version already exists.
- Returns: API metadata including owner, name, specType, version (from X-Version header if available), SwaggerHub URL, and operation type ('create').
- Use case: Rapidly create APIs from natural language descriptions (e.g., "Create a RESTful API for managing a pet store with endpoints for pets, orders, and inventory"), generate API prototypes for proof-of-concept work, or bootstrap new API projects with AI assistance while ensuring compliance with organization standards.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
owner | API owner (organization or user, case-sensitive) | string | Yes |
apiName | API name | string | Yes |
prompt | The prompt describing the desired API functionality. Be specific about resources, operations, and data models. Examples: "Create a RESTful API for managing a pet store with endpoints for pets, orders, and inventory", "Build an API for a blog platform with posts, comments, and users" | string | Yes |
specType | Specification type for the generated API definition. Options: openapi20 (OpenAPI 2.0), openapi30x (OpenAPI 3.0.x, default), openapi31x (OpenAPI 3.1.x), asyncapi2xx (AsyncAPI 2.x), asyncapi30x (AsyncAPI 3.0.x)Default: openapi30x | string | No |
standardize_api
- Purpose: Standardize and fix an API definition using AI to ensure compliance with governance policies. Scans the API definition for standardization errors and automatically fixes them using SmartBear AI. If errors are found, they will be sent to SmartBear AI to generate a corrected definition, which is then saved back to the registry.
- Returns: Standardization result including a message, the number of errors found, and the fixed definition if successful. Also includes details about each error (description, line number, severity). If the fixed definition was saved, the response includes a
urlto view the API in SwaggerHub (server returnssavedVersion); otherwiseurlis omitted. - Use case: Automatically fix API definitions that fail standardization scans, ensure governance compliance in existing APIs, or clean up imported/legacy API definitions to meet current organization standards.
- Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
owner | API owner (organization or user, case-sensitive) | string | Yes |
api | API name (case-sensitive) | string | Yes |
version | Version identifier | string | Yes |
newVersion | The version to save the fixed definition as (e.g. 1.0.1). Omitting this will overwrite the current version - prefer providing a patch bump (e.g. 1.0.0 -> 1.0.1) unless the user specifies otherwise. | string | No |
patch_api
- Purpose: Apply targeted search/replace edits to an existing API definition in the SwaggerHub Registry, without regenerating the whole specification. Only OpenAPI and AsyncAPI definitions are supported - any other specification type is rejected. Edits are applied to the YAML source, so fetch it first with
get_api_definitionusingformat: 'text'and withoutresolvedorflatten, since those options transform the definition and edits based on them will not match the stored source. All edits are atomic: nothing is saved unless every edit applies. - Returns: On success,
saved: truetogether with the operation type (createorupdate), the saved version, and the SwaggerHub URL. If any edit fails, nothing is saved and the response containssaved: falseplus afailedlist, where each entry holds the editindex, itsoldString, theerror(no_matchwhen the text was not found,ambiguouswhen it matched more than once withoutreplaceAll), andmatchCount. - Use case: Fix individual findings from a standardization scan or a review (e.g. add a missing
operationId, correct a description, add a response) while leaving the rest of the definition byte-for-byte unchanged. Prefer this overcreate_or_update_apiwhen only small parts of a large definition need to change. - Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
owner | API owner (organization or user, case-sensitive) | string | Yes |
apiName | API name (case-sensitive) | string | Yes |
version | Version of the definition to patch (base version, e.g. 1.0.0) | string | Yes |
newVersion | Version to save the patched definition as (e.g. 1.0.1). Must not already exist and is always created as private. Omit to overwrite the base version, which keeps its current visibility. The definition's info.version is updated automatically - do not add an edit for it. | string | No |
edits | Search/replace edits applied sequentially to the YAML definition. Min: 1, Max: 50 | array | Yes |
Each entry in edits accepts:
| Parameter | Description | Type | Required |
|---|---|---|---|
oldString | Exact text to find in the YAML definition, including indentation and newlines, copied from get_api_definition with format: 'text'. Must match exactly one location unless replaceAll is true. For repeated text (e.g. responses:, description: OK), start from the nearest unique parent key such as a path name, schema name, or operationId. | string | Yes |
replaceString | Replacement text. Repeat the quoted context unchanged and change only the minimal part. An empty string deletes the matched text. | string | Yes |
replaceAll | Replace every occurrence of oldString instead of requiring a unique match.Default: false | boolean | No |
list_organizations
- Purpose: Get organizations for the authenticated user. Returns a list of organizations that the authenticating user is a member of. On-Premise admins get a list of all organizations in the system.
- Returns: Paged list of organizations, each including id, name, description, url, and memberCount.
- Use case: Discover which organizations the current user belongs to before performing organization-scoped operations (e.g.,
scan_api_standardization, creating APIs under a specific owner), or enumerate organizations on On-Premise installations. - Parameters:
| Parameter | Description | Type | Required |
|---|---|---|---|
q | Search organizations by partial or full name (case-insensitive) | string | No |
sortBy | The property to sort the results by. Options: NAME, EMAIL | string | No |
order | Sort order. Options: ASC, DESC | string | No |
page | 0-based index of the page to return | number | No |
pageSize | Number of results per page to return. Min: 1, Max: 1000 | number | No |
Configuration
To use Swagger Studio tools, you need to configure the SWAGGER_API_KEY environment variable with your Swagger API token.
On-Premise Installations
If you're using an on-premise Swagger Studio installation, you also need to configure the following environment variables to point to your custom API endpoints:
SWAGGER_PORTAL_BASE_PATH- Base path for Portal API requests (e.g.,https://your-domain/portal-api/v1)SWAGGER_REGISTRY_BASE_PATH- Base path for Registry API requests (e.g.,https://your-domain/registry-api)SWAGGER_UI_BASE_PATH- Base URL for the SwaggerHub UI (e.g.,https://your-domain/swaggerhub)
These variables are optional for cloud-based Swagger Studio users, as the default values point to the public Swagger cloud endpoints.
Common Use Cases
- API Discovery: Use
search_apis_and_domainsto find existing APIs in your Swagger Studio. - API Integration: Retrieve specific API definitions with
get_api_definitionfor development or testing purposes. - API Creation: Create new APIs using
create_or_update_apiwith custom definitions orcreate_api_from_promptwith natural language descriptions powered by AI. - API Governance: Check API definitions for structural errors with
validate_api, validate them against organization standards usingscan_api_standardizationto ensure compliance with governance policies, then usestandardize_apito automatically fix any violations. - AI-Powered API Development: Leverage
create_api_from_promptto rapidly prototype APIs from natural language, then usestandardize_apito ensure they meet your organization's standards.