A domain is a library of common components – such as parameters, responses and data models – that are used across multiple API definitions. API definitions cannot use domains unless they were created with the same API type and version (e.g., an OpenAPI version 2.0 domain cannot be used with an OpenAPI version 3.0 API definition file). If you have installed Enterprise (on-premise), your software version may not support domains. OpenAPI domains have been supported since v. 1.19.3.

Domain examples

go.gifOpenAPI 3.0 Domain Example

go.gifOpenAPI 2.0 Domain Example

go.gifAsyncAPI Domain Example

Create and manage domains

Like APIs, domains can be public or private, unpublished drafts or published. You can have different versions of a domain, rename it, or transfer the ownership to another user or organization.

go.gifCreating a Domain

go.gifReferring to a Domain

go.gifManaging Domains

go.gifRenaming Domains

go.gifTransferring Domain Ownership

Domain syntax

The domain structure is similar to API definitions. Domains can be defined by using the OpenAPI 2.0, OpenAPI 3.0 or AsyncAPI syntax.

Specification Version

When you create a domain, you specify the specification version of the domain, swagger: '2.0', openapi: 3.0.0 or asyncapi: 2.x.x. Use the same specification version as in your APIs – SwaggerHub supports cross-referencing only within the same specification and version.

The specification version defines the domain syntax and the available component types.

Existing domains without a version identifier are assumed to be swagger: '2.0'.

Info section

The info section is optional, but it can be used to give your domain a title, description and developer contact information, as shown in the example below. SwaggerHub displays this information in the interactive documentation and in MY hub.

  title: Components
  description: Common components for Acme REST APIs.
    name: Core team
    email: [email protected]
    name: Apache 2.0
  version: 1.0.1

The info section structure is the same as in APIs. See Info Object (OpenAPI) or Info Object (AsyncAPI).

Channels (AsyncAPI only)

For AsyncAPI, the channels object is required, however for domains this must be empty.

channels: {} 


The components of APIs are specified at the root level of the domain:


Like API definitions, domains can contain extensions – arbitrary keys with the x- prefix. You can use them to add custom metadata to your domains and components. Extension properties can be used almost anywhere in domains, but not directly under the parameters, responses and similar keys.

openapi: 3.0.0

      in: query
      name: filter
      x-beta: true  # <-------
        type: string
      description: Filter string

How to reference domains

To reference the domain components in an API, use absolute $ref links as follows:

# OpenAPI 2.0

# OpenAPI 3.0

# AsyncAPI 2.x

or if you use SwaggerHub On-Premise:

# OpenAPI 2.0

# OpenAPI 3.0
$ref: http(s)://SWAGGERHUB/v1/domains/OWNER/DOMAIN/VERSION#/components/TYPE/COMPONENT_NAME

# AsyncAPI 2.x
$ref: http(s)://SWAGGERHUB/v1/domains/OWNER/DOMAIN/VERSION#/components/TYPE/COMPONENT_NAME

See Referring to a Domain for details.

See Also

Publication date: