Import from OpenAPI / Swagger
If you already describe your API with an OpenAPI 3.x or Swagger 2.0 specification, you do not have to recreate every endpoint by hand in LoadFocus. Import the spec and LoadFocus generates one API monitor per operation, with the method, the URL and a status-code assertion, in a single step.
Both JSON and YAML are accepted. The checks are created in your active team and count against your plan limits, exactly as if you had created them by hand.
How it works
Section titled “How it works”- Open API Monitoring and go to the checks list.
- Click New Monitor, then choose Import OpenAPI in the Synthetic group.
- Choose Paste spec and paste the spec text, or choose From URL and enter an address that LoadFocus fetches for you.
- Set the Frequency, decide whether Activate imported checks now is ticked, and fill in Base URL override only if your spec has no server.
- Click Import. LoadFocus parses the spec and creates a check for every operation.
For each operation LoadFocus builds:
- the request URL from the spec's
servers(OpenAPI 3) orschemes+host+basePath(Swagger 2), joined with the operation path; - the HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS);
- a status-code assertion: the first documented 2xx success code when the spec declares one, otherwise a check that the status code is below 400;
- a readable name from the operation's
operationId(orMETHOD /path).
Path parameters such as /users/{id} are filled in with the parameter's example, default or first enum value when the spec provides one. Otherwise 1 is used for integer and number parameters and the text example for the rest. Review those checks after import so they point at a real resource.
Every imported check runs from one location, US East (N. Virginia). Edit a check afterwards if you want more locations.
Source: paste or URL
Section titled “Source: paste or URL”- Paste spec: copy the contents of your
openapi.json,openapi.yaml,swagger.jsonorswagger.yamlinto the box. A spec can be up to about 5 MB and describe up to 500 operations. - From URL: enter the public address of your spec (for example
https://api.example.com/openapi.json). The address must start withhttps://, redirects are not followed, and internal or private addresses are rejected. The same size limit applies.
Base URL
Section titled “Base URL”LoadFocus reads the base URL from the spec: the first entry of servers for OpenAPI 3, or schemes, host and basePath for Swagger 2. If the spec declares none (or its first server is a relative path), fill in Base URL override, for example https://api.example.com. The override is only a fallback: when the spec has a usable server, that server is used and the override is ignored. To import against a staging host, put it first in the spec's servers list.
Frequency and activation
Section titled “Frequency and activation”- Frequency: how often every imported check runs. Choose 5, 10, 15 or 30 minutes, or 1 hour; 5 minutes is the default.
- Activate (Activate imported checks now): when ticked, the checks start running immediately. Untick it to import them paused, review them, and activate the ones you want. This is useful when your spec contains write operations (POST, PUT, DELETE) that you do not want a scheduled monitor to call repeatedly.
What you should review after import
Section titled “What you should review after import”- Write operations: a scheduled monitor calls the endpoint on every run. For POST, PUT, PATCH and DELETE operations, confirm you really want them monitored, or import paused and enable only the safe ones.
- Path parameters: make sure substituted values point at a resource that exists.
- Authentication: imported checks have no headers at all. Add the headers your API needs, such as an API key or a token, using variables and secrets so authenticated endpoints return their real status.
- Request bodies: for an OpenAPI 3 operation whose request body has an example, that example is sent as the body. In every other case, including all Swagger 2 operations, the request is sent without a body.
Plan limits
Section titled “Plan limits”Imported checks count against your plan's API-monitor limit, the same as checks you create by hand. If a spec has more operations than your remaining quota, LoadFocus creates as many as fit and reports how many were created and how many were skipped, so nothing is created silently beyond your plan.
Keeping monitors in sync
Section titled “Keeping monitors in sync”A one-off import is a fast way to get started. If you want your monitors to stay in lockstep with your API definition over time, manage them as version-controlled files with Monitoring as Code and reconcile them from CI.