Define & Validate APIsManage API Definitions

Specify API Metadata

Add an APIMatic Metadata file next to your API definition to filter endpoints, properties, and parameters, or override servers, authentication, and other details.

The APIMatic Metadata file is a JSON file that sits next to your API definition and tells APIMatic how to process it.

Add the metadata file

  1. Create a file whose name starts with APIMATIC-META, for example APIMATIC-META.json.

  2. Put it in the same folder as your API definition, not in a subfolder:

    src/
      spec/
        openapi.yaml
        APIMATIC-META.json
  3. Add the settings you need. The file must be valid JSON.

APIMatic checks the file against the Metadata File Validation ruleset when it validates your definition.

src/spec/APIMATIC-META.json
{
  "ImportSettings": {
    "PreferJsonSchemaNameOverTitle": true,
    "PreferSwaggerOperationSummaryOverId": false
  },
  "ExportSettings": {
    "ExportExtensions": false,
    "EncodeUrlParamsInPostman": true
  },
  "MergeConfiguration": {
    "MergeApis": false
  }
}

Top-level sections

SectionWhat it controlsSee
ImportSettingsHow the definition is readImport and Export Settings
ExportSettingsHow the definition is written when you transform itImport and Export Settings
ValidationConfigurationWhich linting rulesets and rules run, and at what severityConfigure Validation
MergeConfigurationMerging several definitions into oneMerge Multiple API Definitions
Filtering keysRemoving endpoints, properties, and parameters by tagFilter your definition
Override keysReplacing the description, contact, authentication, servers, and headersOverride parts of your definition

Filter your definition

Filtering keys remove parts of your definition by tag, so you can publish a subset of your API without keeping a separate copy of it. Add them at the top level of the metadata file.

Where tags come from

ItemTag source
Endpoints (OpenAPI 2.0 and 3.x)The operation's tags
Endpoints (RAML 1.0)The (x-tags) annotation on the method
Schema propertiesx-tags on the property
Parametersx-tags on the parameter

Endpoints

KeyTypeWhat it does
RemoveEndpointsWithTagsarray of stringsRemoves endpoints that have any of these tags. Runs first.
KeepEndpointsWithTagsarray of stringsKeeps only endpoints that have any of these tags. Runs after RemoveEndpointsWithTags.
MaximumAllowedEndpointsintegerRemoves endpoints beyond this number. Runs after the tag filters.

Removing endpoints also removes models and authentication schemes that only those endpoints used.

{
  "RemoveEndpointsWithTags": ["internal", "deprecated"],
  "KeepEndpointsWithTags": ["public"]
}

Properties and parameters

KeyTypeWhat it does
RemoveSchemaPropertiesWithTagsarray of stringsRemoves schema properties that have any of these tags, then removes schemas nothing uses any more. Examples are updated to match.
RemoveParametersWithTagsarray of stringsRemoves path, query, header, and cookie parameters that have any of these tags, then removes schemas nothing uses any more.

Removing schema properties can change your API in ways that are hard to spot. Removing a discriminator property breaks polymorphic schemas, a property removed from a parent is removed from its allOf children, oneOf and anyOf options can become indistinguishable, and descriptions or minProperties limits can stop matching the schema. Check the result before you publish it.

By default, removed properties are also removed from examples. To keep them, set the import setting RemoveUndeclaredPropertiesFromExample to false; they then show up as additional properties in your portal and generated samples.

Everything at once

RemoveInformationWithTags (array of strings) removes endpoints, schema properties, and parameters with these tags in one step. It's the same as setting RemoveEndpointsWithTags, RemoveSchemaPropertiesWithTags, and RemoveParametersWithTags to the same list.

{
  "RemoveInformationWithTags": ["internal"]
}

Override parts of your definition

Override keys replace parts of your definition with the values in the metadata file.

Overrides are for advanced use. Contact APIMatic support before you use them.

Description

Description (string) replaces the API description.

Contact

KeyTypeDescription
Contact.NamestringContact name
Contact.UrlstringContact URL
Contact.EmailstringContact email

Authentication

KeyTypeDescription
TypestringAuthentication type. See the values below.
Parametersarray of { Name, Description, DefaultValue }Authentication parameters
Scopesarray of { Name, Value, Description }OAuth 2.0 scopes. Name is a readable label and Value is the scope sent to the server.
OAuth2AuthorizationServerstringName of the server used as the base URL of the authorization endpoint
AuthorizationUrlstringPath of the authorization endpoint
OAuth2ServerstringName of the server used as the base URL of the token endpoint
AccessTokenUrlstringPath of the token endpoint
OAuth2ClientIdExamplestringExample client ID
OAuth2ClientSecretExamplestringExample client secret
OAuth2UsernameExamplestringExample username
OAuth2PasswordExamplestringExample password

Type takes one of these values:

None · Basic · OAuth_v2_BearerToken · OAuth_v2_WebServerFlow · OAuth_v2_TwoLeggedFlow_ClientCredentials · OAuth_v2_ImplicitGrantFlow_UserAgent · OAuth_v2_Resource_Owner_Password · OAuth_v2_Password_Only · CustomQuery · CustomHeader · CustomField · JWT · CookieAuth

ServerConfiguration

KeyTypeDescription
DefaultEnvironmentstringEnvironment used by default across the API
DefaultServerstringServer used by default. Endpoints can set their own.
EnvironmentsarrayEach has Name, Description, and Servers, an array of { Name, Url }
ParametersarrayParameters used in server URLs. Each has Name, Description, Type (String, Number, Number Enumeration, or String Enumeration), and DefaultValue.
{
  "ServerConfiguration": {
    "DefaultEnvironment": "production",
    "DefaultServer": "default",
    "Environments": [
      {
        "Name": "production",
        "Servers": [{ "Name": "default", "Url": "https://api.example.com" }]
      }
    ],
    "Parameters": []
  }
}

AdditionalHeaders

AdditionalHeaders is an array of headers added to every request. Each has Name, Description, and DefaultValue.

On this page