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.
contact_ext-1.0
Swagger schema that extends the return schema for GET
/contacts/{contactId}.- Create the
contact_ext-1.0JSON schema, combinecontact_base-1.0, and extend theContactschema definition to add in the new properties. - Create the
contact_ext-1.0Swagger schema and combine thecontact_base-1.0schema. - Add the following import to the
contact_ext-1.0schema to override thecontactalias 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.
