OpenAPI Validation (JS)
Using the Fastly CLI, create a new project using this starter somewhere on your computer:
Or click the button below to create a GitHub repository, provision a Fastly service, and set up continuous deployment:
The OpenAPI Specification (OAS – originally based on the Swagger Specification) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, additional documentation, or inspection of network traffic.
An OpenAPI definition is a document (or set of documents) that defines or describes an API.
This starter kit makes it possible to define custom request handling logic at the edge, based on whether a request matches an OpenAPI definitions. This means:
✅ Relieving load on origins
✅ Improved API security
Replace the contents of
src/definition.json with your own OpenAPI 3.x definition, and change any references to
httpbin.org to your origin in
fastly.toml – by replacing the
local_server.backends.origin, and the
address (hostname) in
fastly compute serve to try out this Compute@Edge app on your local machine, or
fastly compute publish to publish a new Compute@Edge service.
The default application behavior is to only forward valid requests to the origin, and return a synthetic HTTP 400 response for invalid requests.
OpenAPI validation errors are logged in both cases.
To forward all requests to the origin, set the constant
For more details about other starter kits for Compute@Edge, see the Fastly Developer Hub
Starters are a good way to bootstrap a project. For more specific use cases, and answers to common problems, try our library of code examples.