Global overrides

As part of schema composition, it is possible to extend or compose the JSON schemas referenced from body parameters and responses. To make this kind of change, use the x-gw-schema-import property to make the change globally.

Schema references for parameters and responses are always relative to an alias. Thus, it is possible to override the alias to point a different JSON schema. For example, suppose that the contact_base-1.0 Swagger schema defines the contact alias as pointing to schema contact_base-1.0. The GET /contacts/{contactId} method can then have a response schema $ref value of contact#/definitions/Contact, which then resolves to the Contact definition within the contact_base-1.0 schema.

The following sequence of steps illustrate how to create a contact_ext-1.0 Swagger schema that extends the return schema for GET /contacts/{contactId}.
  1. Create the contact_ext-1.0 JSON schema, combine contact_base-1.0, and extend the Contact schema definition to add in the new properties.
  2. Create the contact_ext-1.0 Swagger schema and combine the contact_base-1.0 schema.
  3. Add the following import to the contact_ext-1.0 schema to override the contact alias to point to the extension schema.
    x-gw-schema-import
      contact : contact_ext-1.0

The result is that all references inherited from contact_base-1.0 that reference the contact alias now point to the equivalent definitions in the contact_ext-1.0 JSON schema instead. During combination, PolicyCenter compares the JSON schemas referenced from each body-type parameter or response schema to ensure they are appropriately backwards compatible.