logo
logo

Test a domain

In the following example, we use Swagger Petstore to test a sample domain called Demo domain. A domain is a library of specifications and mappings, such as parameters, responses, and data models used across multiple API definitions. The domain represents a unique business case and the mechanism to group and version the related domain specifications. For more details about creating a new domain, see domain management.

Note

Swagger Petstore is a tool that enables exploring an OpenAPI.

The demo domain used in this example, is as follows:


Demo domain Description
Name Demo domain.
Enabled Active.
Identifier DemoDomain.
Specification
Click to expand

[ { "version": 1, "status": 0, "entity_views": { "M.Asset": { "identifier": "M.Asset", "entity_definition_name": "M.Asset", "version": "1.0", "public_links": true, "languages": [ "en-US" ], "properties": [ "Title", "FileName", "Description" ], "system_properties": { "id": false, "identifier": true, "version": true, "created_on": { "language": "en-US", "format": "dddd, MMMM dd, yyyy HH:mm:ss", "utc_time_offset": "03:00" }, "modified_on": { "language": "en-US" }, "created_by": false, "modified_by": false }, "relations": [ { "relation_name": "FinalLifeCycleStatusToAsset", "relation_role": 1, "view": { "identifier": "M.Final.LifeCycle.Status", "entity_definition_name": "M.Final.LifeCycle.Status", "version": 1, "public_links": false, "properties": [ "StatusValue" ], "system_properties": {}, "relations": [], "renditions": [] } } ], "renditions": [ { "rendition_link_name": "preview" }, { "rendition_link_name": "thumbnail" } ] } } } ]

Status None.
Note

Swagger Petstore is a tool that enables exploring an OpenAPI.

To test a domain:

Configure the test

  1. In Swagger, in the box at the top of the page, enter the base URL of the instance https://xxxx.stylelabs.com appended with `/openapi/v3/ for OpenAPI version 3, and the identifier of the domain as shown in the following code:

    https://xxxx.stylelabs.com/openapi/v3/DemoDomain

  2. Click Explore to see the available specifications. In the results, we can see that a GET method is used to retrieve information from the M.Asset entity definition. An entityID is expected.

To make a successful call you need:

Generate an API Token

To generate an API token in Sitecore Content Hub:

  1. On the menu bar, click Manage .

  2. On the Manage page, click Users.

  3. On the Users page, next to the required user, click API token :

  4. Click Create new.

  5. Click Copy token and, in the API token dialog box, click Copy token.

  6. Return to Swagger Petstore, and click Authorize:

  7. Paste the copied API token in the X-Auth-Token (apiKey) box, click Authorize, and click Close:

Get an asset ID

To get an asset ID:

  1. On the Sitecore Content Hub menu, click Assets.

  2. Pick an asset, and go to its details page.

  3. On the Assets page, select an asset and, on the Asset details page, copy the asset ID shown at the end of the URL.

    You can also find the asset ID on the System tab, under System properties, field ID:

  4. Return to the Swagger Petstore, and click Try it out:

  5. In the entityId field, paste the asset ID:

    Execute the test

To determine the success or failure of the request, use the Execute feature. To execute the text:

  • In Swagger, click Execute.

  • The server returns code 200 indicating a successful request. The response body displays the asset properties and associated metadata:

Can we improve this article ? Provide feedback