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
| Available in: Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, and Developer Editions |
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
integerand the default value provided is50.2, the default value doesn’t translate to Apex. - For
integerdefaults to show up, a format must be specified, for example,int32orint64.
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
}
}