---
schema_version: "1"
id: 0602a1cbc7f84d7d16b86d7a137272826a9bffa69fe72b3cde2bed8c6ddf3d6d
title: Defaults and Default Values
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/external_services_schema_apex_defaults.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.external_services_schema_apex_defaults.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 365c2705ef89bbf83e361d51333be5d8a6a5132c368e3ca192e0442bb2f83e62
description: Learn about External Services' support for defaults. For OpenAPI 2.0, default values set on properties are used. For OpenAPI 3.0 schemas, the "outermost" default is used. Non-supported configurations are ignored.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Defaults and Default Values

Learn about External Services' support for defaults. For OpenAPI 2.0, default values set on `properties` are used. For OpenAPI 3.0 schemas, the "outermost" default is used. Non-supported configurations are ignored.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions</td></tr></tbody></table>

## Default Values

For both OpenAPI 2.0 and 3.0 specifications,

- The type of the default value must match the type of the property/parameter. For example, if the type is `integer` and the default value provided is `50.2`, the default value doesn’t translate to Apex.
- For `integer` defaults to show up, a format must be specified, for example, `int32` or `int64`.

The following sections describe Open API version-specific support for defaults.

## OpenAPI 2.0 Default Definitions

For OpenAPI 2.0 schemas, External Services supports a subset of primitive data types for default values set on object properties. These primitive data types are limited to:

- string
- number
- integer
- boolean

For OpenAPI 2.0 schemas, only the default values set on `properties` are used.

For example, in the code snippet below, the default set for the `month` property is supported. In the Apex class, you see a comment in the birthday object with

`// Default value: January`

However, the default value that's set at the object level

`"default": { "month": "December" }`

is ignored.

```
"birthday": { 
    "type": "object", 
    "properties": { 
        "month": { 
            "type": "string", 
            "default": "January" 
        }, 
        "day": { 
            "type": "integer" 
        }, 
        "year": { 
            "type": "integer" 
        } 
    }, 
    "default": { 
        "month": "December" 
    } 
}
```

Default values set anywhere else other than on the property (such as `object/composed object`) are ignored.

In the following example, the default value is 123 because that's what is set on the property.

```
"Fax": { 
    "allOf": [
        { 
            "$ref": "#/components/schemas/Contact" 
        }, 
        { 
            "type": "object", 
            "properties": { 
                "faxNumber": { 
                    "type": "integer", 
                    "default": 123 
                } 
            } 
        }, 
        { 
            "default": { 
                "faxNumber": 456 
            } 
        } 
    ], 
    "default": { 
        "faxNumber": 789 
    } 
}
```

## OpenAPI 3.0 Default Definitions

For OpenAPI 3.0 schemas, the "outermost" `default` is used. For the same birthday object registered using an OAS3 schema,

```
"birthday": { 
    "type": "object", 
    "properties": { 
        "month": { 
            "type": "string", 
            "default": "January" 
        }, 
        "day": { 
            "type": "integer" 
        }, 
        "year": { 
            "type": "integer" 
        } 
    }, 
    "default": { 
        "month": "December" 
    } 
}
```

the comment in the Apex class is

`// Default value: December`

because the `default` set at the object level is the outermost one, and is therefore the one that's used.

Defaults set at the composed object level for `anyOf` and `oneOf` object compositions aren’t supported. In the following example, the

`"default": { "phoneNumber": "1 (000) 000 0000"`

isn't used.

```
"Phone": { 
    "oneOf": [
        { 
            "$ref": "#/components/schemas/Contact" 
        }, 
        { 
            "type": "object", 
            "properties": { 
                "phoneNumber": { 
                    "type": "string" 
                } 
            } 
        } 
    ], 
    "default": { 
        "phoneNumber": "1 (000) 000 0000" 
    } 
}
```

However, defaults set at the composed object level for `allOf` are supported. Again, in this scenario, the "outermost" default values override the others. In the following fax object example, if the only default set was `123`, then that’s what is shown in the Apex class. But if both `123` and `456` were set, `456` would override `123` and `456` would be shown in the apex class, and similarly if `123`, `456`, `789` were all set, `789` would be shown in the apex class.

```
"Fax": { 
    "allOf": [
        { 
            "$ref": "#/components/schemas/Contact" 
        }, 
        { 
            "type": "object", 
            "properties": { 
                "faxNumber": { 
                    "type": "integer", 
                    "default": 123 
                } 
            } 
        }, 
        { 
            "default": { 
                "faxNumber": 456 
            } 
        } 
    ], 
    "default": { 
        "faxNumber": 789 
    } 
}
```