OpenAPI Specification (OAS)

Formerly known as Swagger specification, the OAS has emerged as a widely adopted way of documenting REST APIs. It offers a standard format with large tooling support. Instead of trying to deduce the intent of an API from its behavior or source code, the standard OpenAPI contract makes it easier to communicate this clearly.

One of the key functions that the standard contract can enable is API security, because it provides a way for developers, operations, and security people across teams to speak in common language. When all teams building both the API and the infrastructure the API is going to sit in can clearly communicate the intent, requirements, and outcome, it is also easier and more reliable to uncover, understand, and mitigate security risks. This idea is in the core of 42Crunch Platform.

The OAS allows to clearly specify a contract, the terms and conditions of using the API and the functions it offers. This contract takes the form of an OpenAPI definition, which describes among other things:

  • The functions (operations) that the API offers
  • The data that the API requires or accepts as input for each function
  • The data that the API returns as a response to calling a particular function
  • The security measures protecting the API
  • The linking and connections that the API has to other APIs

The OAS enables developing and utilizing various tools throughout your API's life cycle, such as:

  • Automatically generated API documentation
  • Testing tools
  • Code generation tools for generating servers and clients
  • API firewalls and firewall rules to protect API infrastructure

The OAS does not require completely rewriting your existing APIs, or binding any software to your service. You simply describe the capabilities of the service as the OAS specifies.

OAS versions

There are currently three versions of the OAS that have significant differences between them:

  • Version 2
  • Version 3.0.x
  • Version 3.1.x

Schema object definitions in the OAS are an extended subset of the JSON Schema Specification Wright Draft 00, and for the most part correspond to how JSON schemas are defined, with some exceptions. Two notable exceptions are that in JSON schema, you can define the property type as an array, often to allow for null properties, and null is a valid type. However, in the OAS, arrays in type or null as a type are not supported.

If you must allow for null properties, in the OAS v3, you can add the property nullable to your schema and set it to true.

The OAS v2 does not have the property nullable. Instead, as a workaround, you can add the OAS extension x‑nullable to your schema and set it to true. Some tooling, such as all features in 42Crunch Platform, support this workaround, but the support is not universal. Using x‑nullable together with required in your schemas can also cause problems. For proper support, we recommend switching from OAS v2 to OAS v3.