Define & Validate APIsOpenAPI Extensions

OpenAPI Extensions Overview

The APIMatic extensions you can add to an OpenAPI 3.x or Swagger 2.0 definition, and what APIMatic imports from each.

OpenAPI lets tools define their own properties, called specification extensions, whose names start with x-. APIMatic reads the extensions on these pages when it imports your OpenAPI 3.x or Swagger 2.0 definition. Use them to describe parts of your API that the standard can't, such as multiple environments, pagination, or webhook signature verification.

You add an extension next to the standard properties of the object it applies to:

openapi: 3.0.3
info:
  title: Payments API
  version: 1.0.0
  x-server-configuration:
    default-environment: production
    default-server: default
    environments:
      - name: production
        servers:
          - name: default
            url: https://api.example.com

Supported extensions

ExtensionApplies toVersionsWhat it does
x-server-configurationInfo Object3.x, 2.0Defines environments, servers, and server URL parameters
x-server-nameOperation Object3.x, 2.0Sets the server an endpoint calls
x-additional-headersSecurity Scheme Object3.x, 2.0Adds headers to every request
x-rename-username-as, x-rename-password-asSecurity Scheme Object3.x, 2.0Renames the Basic authentication credentials
OAuth 2.0 extensionsOAuth Flow Object (3.x), Security Scheme Object (2.0)3.x, 2.0Adds examples, client authentication options, token revocation, and default scopes
x-security-options-metaOpenAPI Object, Operation Object3.x, 2.0Names and describes each security option
x-deprecation-detailsOperation Object3.x, 2.0Adds a message and version to a deprecated endpoint
x-unwrap-bodyOperation Object3.x, 2.0Imports the properties of the request body as separate body parameters
x-unique-nameParameter Object3.xGives a parameter a different name in SDKs and docs
x-exampleParameter Object2.0Adds an example value to a parameter
x-paginationMedia Type Object of a response3.xDescribes how the endpoint paginates its results
x-sse-sentinelMedia Type Object of a response3.xSets the value that ends a Server-Sent Events stream
x-enum-elementsSchema Object, Parameter Object (2.0)3.x, 2.0Names and describes each enum value
x-enum-model-nameSchema Object (3.x), Parameter Object (2.0)3.x, 2.0Sets the name of an enum model
x-discriminator-valueDiscriminator Object (3.x), Schema Object (2.0)3.x, 2.0Sets a custom discriminator value
x-is-dynamicSchema Object3.x, 2.0Imports a schema as a dynamic type
x-exception-model-nameSchema Object3.x, 2.0Sets the name of the error model created from an error response
x-webhooks, x-callbacksOpenAPI Object3.xGroups webhooks or callbacks, routes events, and verifies signatures
x-webhook-group, x-callback-groupOperation Object of a webhook or callback3.xAssigns a webhook or callback to a group
x-image-uriInfo Object3.x, 2.0An absolute URL of an image for the API

APIMatic also reads x-tags on parameters and schema properties to filter your definition. See Specify API Metadata.

Besides these extensions, APIMatic reads two custom values of the standard format property for date-time types. See Date-time formats.

Validation

APIMatic checks most of these extensions when it validates your definition, for example that a default server exists or that a pagination pointer references an existing property. The rules are listed with the rest of the OpenAPI rules in OpenAPI v3 APIMatic Linting, and the checks that run after import are in APIMatic CodeGen Validation. For how to change their severity, see Configure Validation.

Extensions for the v3 generator

APIMatic still reads x-codegen-settings and x-operation-settings, which carry settings for the v3 code generator, and the test case extensions such as x-unitTests and x-testValue, which drive SDK test generation. Codegen v4 doesn't use CodeGen settings or test generation, so these pages don't cover them.

On this page