The following code summarizes the shared components that can be used for the components object in the API contract:
1components:2 securitySchemes:3 ShopperToken:4 type: oauth25 flows:6 authorizationCode:7 authorizationUrl: https://{shortCode}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/authorize8 tokenUrl: https://{shortCode}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/token9 scopes: {list of available scopes}10 clientCredentials:11 tokenUrl: https://{shortCode}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/token12 scopes: {list of available scopes}13 AmOAuth2:14 type: oauth215 flows:16 authorizationCode:17 authorizationUrl: https://account.demandware.com/dwsso/oauth2/authorize18 tokenUrl: https://account.demandware.com/dwsso/oauth2/access_token19 scopes: {list of available scopes}20 clientCredentials:21 tokenUrl: https://account.demandware.com/dwsso/oauth2/access_token22 scopes: {list of available scopes}23 parameters:24 siteId:25 name: siteId26 in: query27 description: The site of the current request.28 required: true29 schema:30 type: string31 minLength: 132 locale:33 name: locale34 in: query35 description: The locale of the current request.36 required: false37 schema:38 type: string39 minLength: 1
After that, the individual entries can be reused at different places of the schema.
Use of References
The OpenAPI specification allows the use of JSON References in schema files as described here. This avoids defining objects multiple times at different places in the schema, leading to files that are smaller and easier to maintain.
Contrary to OAS, Custom APIs only allow local references, that is, references to objects defined in the same schema file. Specifically, only such references are possible:
$ref: '#/components/parameters/sampleParam'
However, remote and URL references like these are not possible:
Example: Using the system query parameter siteId via a reference:
1components:2 parameters:3 siteId:4 name: siteId5 in: query6 description: The site of the current request.7 required: true8 schema:9 type: string10 minLength: 1
1paths:2 /customers:3 get:4 summary: Get loyalty information for customer5 operationId: getLoyaltyInfo6 parameters:7 - $ref: "#/components/parameters/siteId"