Skip to main content

Announcing Support for Type "any" in API Transformer

· 3 min read

We now announce support in API Transformer for API components that have no specific type or in other words are said to have any type. Until now, a default type (string/object) was assumed for all such cases.

What's New?

Upon transformation of API description files containing components using any type, you can now expect the following changes:

  • JSON schema allows skipping type information to indicate that the schema has no fixed type. This is supported by all API description formats that make use of JSON schema whether as a subset or directly, including OpenAPI (v2.0, v3.x), RAML (v0.8, v1.0), API Blueprint, etc. In APIMatic, all such cases were exported with a default type assumed as object but will now be exported with type any. A few exceptions to this behavior include the following:

    • For OpenAPI v3.x parameter import, the default type for an empty schema was assumed as string but will now be imported/exported as any. See an example of such a parameter below:
      "paths": {
    "/message": {
    "get": {
    "parameters": [
    {
    "name": "value",
    "schema": {

    },
    "in": "query"
    }
    ]
    }
    }
    }
    • For OpenAPI v3.1 form parameters, an empty schema will still be imported/exported as a file type schema as per the rules defined here.
  • RAML v1.0 has an explicit any type which until now was exported as type object but will now be exported as type any.

  • For XML schema export (relevant to export of WSDL and WADL), both object (one with no explicit property declarations) and any types were exported with the native type xsd:anyType. However, now the object type will be exported as a complex type containing <xsd:any> as a sequence element which allows extending the schema with elements not explicitly declared. An example is given below:

    Before:

          <xsd:element name="value" type="xsd:anyType"/>

    Now:

          <xsd:element name="value">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:any/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

How to Avoid Changes in Output?

If you want to avoid any kind of changes to output that are discussed in the previous section, you will need to upload a metadata file along with your API description file with the following configuration settings:

  • An export setting ExportAnyType set to false.
  • If you are using OpenAPI v3, especially with parameters having empty schemas (excluding form parameters), you will need an additional import setting ImportOpenApi3EmptySchema set to false as well.

Example:

{
"ImportSettings": {
"ImportOpenApi3EmptySchema": false
},
"ExportSettings": {
"ExportAnyType": false
}
}