What is an API Template?
An API template is a reusable mock API definition that can be added to your organisation’s catalogue, ready to be instantiated as a mock API in WireMock Cloud. A template is made up of:- A set of stub mappings, plus an OpenAPI document for
RESTtype templates - Metadata such as a name, description, tags and an optional logo
Syncing Templates
You can sync templates using:.wiremock directories, with one template generated per service defined in the
directory’s wiremock.yaml. For each service, the CLI looks for:
openapi.yaml- the OpenAPI document for the service (required forRESTtype services)stub-mappings.yaml- the stub mappings for the service; if omitted, the template is synced with no stub mappingslogo.png,logo.svg,logo.jpg,logo.jpeg,logo.gif, orlogo.webp- a logo for the template (optional)
path attribute on the service in wiremock.yaml. The template’s slug defaults to
the service key but can be overridden using a slug attribute on the service. The template’s name, description, and
tags are taken from the corresponding attributes on the service.
Only services of type
REST and Unstructured can be synced as templates. GraphQL and gRPC services are not yet supported.Options
--wiremock-dir=<path>- A.wiremockdirectory to sync templates from; may be specified multiple times (default:.wiremock)--dry-run- Print what would be synced without making any changes--prune/--no-prune- Remove remote templates not present locally; use--no-pruneto only report them instead (default:--prune)-f, --force- Skip the confirmation prompt when pruning (only valid with--prune)
Examples
Sync templates from the default.wiremock directory:
Pruning removed templates
By default,templates sync removes any templates from the catalogue that no longer have a corresponding local
service. Before deleting anything, it lists the templates it intends to remove and asks for confirmation:
--force to skip this confirmation prompt, or --no-prune to only report the remote-only templates without
deleting them: