2022-02-09 15:18:16 +03:00
# Redoc vendor extensions
2016-02-01 20:23:13 +03:00
2023-07-21 19:40:20 +03:00
You can use the following [vendor extensions ](https://redocly.com/docs/openapi-visual-reference/specification-extensions/ ) with Redoc.
2020-10-13 14:55:45 +03:00
2023-07-11 20:31:52 +03:00
- [Redoc vendor extensions ](#redoc-vendor-extensions )
2023-11-09 18:56:30 +03:00
- [Swagger Object ](#swagger-object )
- [x-servers ](#x-servers )
- [x-tagGroups ](#x-taggroups )
- [How to use with Redoc ](#how-to-use-with-redoc )
- [Tag Group Object ](#tag-group-object )
- [Fixed fields ](#fixed-fields )
- [x-tagGroups example ](#x-taggroups-example )
- [x-ignoredHeaderParameters ](#x-ignoredheaderparameters )
- [How to use with Redoc ](#how-to-use-with-redoc-1 )
- [x-ignoredHeaderParameters example ](#x-ignoredheaderparameters-example )
- [Info Object ](#info-object )
- [x-logo ](#x-logo )
- [How to use with Redoc ](#how-to-use-with-redoc-2 )
- [Logo Object ](#logo-object )
- [Fixed fields ](#fixed-fields-1 )
- [x-logo example ](#x-logo-example )
- [Tag Object ](#tag-object )
- [x-traitTag ](#x-traittag )
- [How to use with Redoc ](#how-to-use-with-redoc-3 )
- [x-traitTag example ](#x-traittag-example )
- [x-displayName ](#x-displayname )
- [Operation Object vendor extensions ](#operation-object-vendor-extensions )
- [x-codeSamples ](#x-codesamples )
- [How to use with Redoc ](#how-to-use-with-redoc-4 )
- [Code Sample Object ](#code-sample-object )
- [Fixed fields ](#fixed-fields-2 )
- [Code Sample Object example ](#code-sample-object-example )
- [Parameter Object ](#parameter-object )
- [x-examples ](#x-examples )
- [How to use with Redoc ](#how-to-use-with-redoc-5 )
- [Response Object vendor extensions ](#response-object-vendor-extensions )
- [x-summary ](#x-summary )
- [How to use with Redoc ](#how-to-use-with-redoc-6 )
- [Schema Object ](#schema-object )
- [x-nullable ](#x-nullable )
- [How to use with Redoc ](#how-to-use-with-redoc-7 )
- [x-extendedDiscriminator ](#x-extendeddiscriminator )
- [How to use with Redoc ](#how-to-use-with-redoc-8 )
- [x-extendedDiscriminator example ](#x-extendeddiscriminator-example )
- [x-additionalPropertiesName ](#x-additionalpropertiesname )
- [How to use with Redoc ](#how-to-use-with-redoc-9 )
- [x-additionalPropertiesName example ](#x-additionalpropertiesname-example )
- [x-explicitMappingOnly ](#x-explicitmappingonly )
- [How to use with Redoc ](#how-to-use-with-redoc-10 )
- [x-explicitMappingOnly example ](#x-explicitmappingonly-example )
## Swagger Object
2024-08-29 20:18:05 +03:00
Extends the OpenAPI root [OpenAPI Object ](https://redocly.com/docs/openapi-visual-reference/openapi )
2020-10-13 14:55:45 +03:00
2023-11-09 18:56:30 +03:00
### x-servers
2020-05-24 23:06:08 +03:00
Backported from OpenAPI 3.0 [`servers` ](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#serverObject ). Currently doesn't support templates.
2017-02-26 00:44:19 +03:00
2023-11-09 18:56:30 +03:00
### x-tagGroups
2016-12-26 00:47:33 +03:00
2023-11-09 18:56:30 +03:00
| Field Name | Type | Description |
2016-12-26 00:47:33 +03:00
| :------------- | :-----------: | :---------- |
2023-07-21 19:40:20 +03:00
| x-tagGroups | [ [Tag Group Object ](#tag-group-object ) ] | A list of tag groups |
2016-12-26 00:47:33 +03:00
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2017-02-28 23:04:24 +03:00
`x-tagGroups` is used to group tags in the side menu.
2023-07-11 20:31:52 +03:00
Before you use `x-tagGroups` , make sure you **add all tags to a group** , since a tag that is not in a group, **is not displayed** at all!
2016-12-26 00:47:33 +03:00
2023-07-21 19:40:20 +03:00
< a name = "tagGroupObject" > < / a >
2023-11-09 18:56:30 +03:00
2023-07-21 19:40:20 +03:00
#### Tag Group Object
2016-12-26 00:47:33 +03:00
Information about tags group
2023-11-09 18:56:30 +03:00
##### Fixed fields
| Field Name | Type | Description |
2016-12-26 00:47:33 +03:00
| :---------- | :--------: | :---------- |
| name | string | The group name |
2024-01-29 19:39:44 +03:00
| tags | [ string ] | List of tags to include in this group |
2016-12-26 00:47:33 +03:00
2023-11-09 18:56:30 +03:00
#### x-tagGroups example
2016-12-26 00:47:33 +03:00
json
```json
{
"x-tagGroups": [
{
"name": "User Management",
"tags": ["Users", "API keys", "Admin"]
},
{
"name": "Statistics",
"tags": ["Main Stats", "Secondary Stats"]
}
]
}
```
yaml
```yaml
x-tagGroups:
- name: User Management
tags:
- Users
- API keys
- Admin
- name: Statistics
tags:
- Main Stats
- Secondary Stats
```
2023-11-09 18:56:30 +03:00
### x-ignoredHeaderParameters
2017-09-21 01:18:38 +03:00
2023-11-09 18:56:30 +03:00
| Field Name | Type | Description |
2017-09-21 01:18:38 +03:00
| :-------------------------- | :-----------: | :---------- |
| x-ignoredHeaderParameters | [ string ] | A list of ignored headers |
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2023-07-11 20:31:52 +03:00
Use `x-ignoredHeaderParameters` to specify header parameter names which are ignored by Redoc.
2017-09-21 01:18:38 +03:00
2023-11-09 18:56:30 +03:00
#### x-ignoredHeaderParameters example
2017-09-21 01:18:38 +03:00
```yaml
swagger: '2.0'
info:
...
tags: [...]
x-ignoredHeaderParameters:
- Accept
- User-Agent
- X-Test-Header
```
2016-12-26 00:47:33 +03:00
2023-11-09 18:56:30 +03:00
## Info Object
2023-07-21 19:40:20 +03:00
Extends the OpenAPI [Info Object ](https://redocly.com/docs/openapi-visual-reference/info/ )
2016-02-01 20:38:21 +03:00
2023-11-09 18:56:30 +03:00
### x-logo
| Field Name | Type | Description |
2016-02-01 20:38:21 +03:00
| :------------- | :-----------: | :---------- |
2023-07-21 19:40:20 +03:00
| x-logo | [Logo Object ](#logo-object ) | The information about API logo |
2016-02-01 20:23:13 +03:00
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2020-10-13 14:55:45 +03:00
`x-logo` is used to specify API logo. The corresponding image is displayed just above the side-menu.
2016-02-01 20:23:13 +03:00
2023-07-21 19:40:20 +03:00
< a name = "logoObject" > < / a >
2023-11-09 18:56:30 +03:00
2023-07-21 19:40:20 +03:00
#### Logo Object
2016-02-01 20:23:13 +03:00
The information about API logo
2020-10-13 14:55:45 +03:00
2023-11-09 18:56:30 +03:00
#### Fixed fields
| Field Name | Type | Description |
2016-02-01 20:38:21 +03:00
| :-------------- | :------: | :---------- |
2024-01-29 19:39:44 +03:00
| url | string | The URL pointing to the spec logo. MUST be in the format of a URL. It SHOULD be an absolute URL so your API definition is usable from any location |
| backgroundColor | string | background color to be used. MUST be RGB color in [hexadecimal format] (https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) |
| altText | string | Text to use for alt tag on the logo. Defaults to 'logo' if nothing is provided. |
| href | string | The URL pointing to the contact page. Default to 'info.contact.url' field of the OAS. |
2016-02-01 20:23:13 +03:00
2023-11-09 18:56:30 +03:00
#### x-logo example
2016-02-01 20:49:57 +03:00
json
```json
2016-02-01 20:23:13 +03:00
{
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"x-logo": {
2019-06-04 15:47:22 +03:00
"url": "https://redocly.github.io/redoc/petstore-logo.png",
2018-08-02 15:27:38 +03:00
"backgroundColor": "#FFFFFF",
"altText": "Petstore logo"
2016-02-01 20:23:13 +03:00
}
}
}
```
2016-02-01 20:49:57 +03:00
yaml
2016-02-01 20:23:13 +03:00
```yaml
2016-02-01 20:49:57 +03:00
info:
version: "1.0.0"
title: "Swagger Petstore"
x-logo:
2019-06-04 15:47:22 +03:00
url: "https://redocly.github.io/redoc/petstore-logo.png"
2016-04-22 16:33:27 +03:00
backgroundColor: "#FFFFFF"
2018-08-02 15:27:38 +03:00
altText: "Petstore logo"
2016-02-01 20:23:13 +03:00
```
2023-11-09 18:56:30 +03:00
## Tag Object
2023-07-21 19:40:20 +03:00
Extends the OpenAPI [Tag Object ](https://redocly.com/docs/openapi-visual-reference/tags/ )
2016-02-01 20:23:13 +03:00
2023-11-09 18:56:30 +03:00
### x-traitTag
| Field Name | Type | Description |
2016-02-01 20:38:21 +03:00
| :------------- | :------: | :---------- |
2019-01-10 18:28:21 +03:00
| x-traitTag | boolean | In Swagger two operations can have multiple tags. This property distinguishes between tags that are used to group operations (default) from tags that are used to mark operation with certain trait (`true` value) |
2016-02-01 20:23:13 +03:00
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2020-10-13 14:55:45 +03:00
Tags that have `x-traitTag` set to `true` are listed in the side-menu but don't have any subitems (operations). It also renders the `description` tag.
2016-02-01 20:23:13 +03:00
This is useful for handling out common things like Pagination, Rate-Limits, etc.
2023-11-09 18:56:30 +03:00
#### x-traitTag example
2016-02-01 20:49:57 +03:00
json
2016-02-01 20:23:13 +03:00
```json
{
"name": "Pagination",
"description": "Pagination description (can use markdown syntax)",
"x-traitTag": true
}
```
2016-02-01 20:49:57 +03:00
yaml
2016-02-01 20:23:13 +03:00
```yaml
name: Pagination
description: Pagination description (can use markdown syntax)
x-traitTag: true
```
2023-11-09 18:56:30 +03:00
### x-displayName
2019-02-26 10:58:18 +03:00
2023-11-09 18:56:30 +03:00
| Field Name | Type | Description |
2019-02-26 10:58:18 +03:00
| :------------- | :------: | :---------- |
| x-displayName | string | Defines the text that is used for this tag in the menu and in section headings |
2023-11-09 18:56:30 +03:00
## Operation Object vendor extensions
2023-07-21 19:40:20 +03:00
Extends the OpenAPI [Operation Object ](https://redocly.com/docs/openapi-visual-reference/operation/ )
2020-10-13 14:55:45 +03:00
2023-11-09 18:56:30 +03:00
### x-codeSamples
| Field Name | Type | Description |
2016-02-01 20:38:21 +03:00
| :------------- | :------: | :---------- |
2023-07-21 19:40:20 +03:00
| x-codeSamples | [ [Code Sample Object ](#code-sample-object ) ] | A list of code samples associated with operation |
2016-02-01 20:23:13 +03:00
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2022-02-09 15:18:16 +03:00
`x-codeSamples` are rendered on the right panel in Redoc.
2016-02-01 20:23:13 +03:00
2023-07-21 19:40:20 +03:00
< a name = "codeSampleObject" > < / a >
2023-11-09 18:56:30 +03:00
### Code Sample Object
2016-02-01 20:23:13 +03:00
Operation code sample
2020-10-13 14:55:45 +03:00
2023-11-09 18:56:30 +03:00
#### Fixed fields
| Field Name | Type | Description |
2016-02-01 20:38:21 +03:00
| :---------- | :------: | :----------- |
| lang | string | Code sample language. Value should be one of the following [list ](https://github.com/github/linguist/blob/master/lib/linguist/popular.yml ) |
2023-07-11 20:31:52 +03:00
| label | string? | Code sample label, for example `Node` or `Python2.7` , _optional_ , `lang` is used by default |
2016-02-01 20:38:21 +03:00
| source | string | Code sample source code |
2016-02-01 20:23:13 +03:00
2023-11-09 18:56:30 +03:00
#### Code Sample Object example
2016-02-01 20:49:57 +03:00
json
```json
2016-02-01 20:23:13 +03:00
{
"lang": "JavaScript",
"source": "console.log('Hello World');"
}
```
2016-02-01 20:49:57 +03:00
yaml
2016-02-01 20:23:13 +03:00
```yaml
2016-02-01 20:49:57 +03:00
lang: JavaScript
source: console.log('Hello World');
2016-02-01 20:23:13 +03:00
```
2016-08-31 22:45:34 +03:00
2023-11-09 18:56:30 +03:00
## Parameter Object
2023-07-21 19:40:20 +03:00
Extends the OpenAPI [Parameter Object ](https://redocly.com/docs/openapi-visual-reference/parameter/ )
2020-10-13 14:55:45 +03:00
2023-11-09 18:56:30 +03:00
### x-examples
2017-03-09 13:55:23 +03:00
| Field Name | Type | Description |
| :------------- | :------: | :---------- |
2023-07-21 19:40:20 +03:00
| x-examples | [Example Object ](https://redocly.com/docs/openapi-visual-reference/example/ ) | Object that contains examples for the request. Applies when `in` is `body` and mime-type is `application/json` |
2017-03-09 13:55:23 +03:00
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2022-02-09 15:18:16 +03:00
`x-examples` are rendered in the JSON tab on the right panel in Redoc.
2017-03-09 13:55:23 +03:00
2023-11-09 18:56:30 +03:00
## Response Object vendor extensions
2023-07-21 19:40:20 +03:00
Extends the OpenAPI [Response Object ](https://redocly.com/docs/openapi-visual-reference/response/ ).
2018-06-01 16:50:07 +03:00
2023-11-09 18:56:30 +03:00
### x-summary
| Field Name | Type | Description |
2018-06-01 16:50:07 +03:00
| :------------- | :------: | :---------- |
| x-summary | string | a short summary of the response |
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2020-10-13 14:55:45 +03:00
If specified, you can use `x-summary` as the response button text, with description rendered under the button.
2023-11-09 18:56:30 +03:00
## Schema Object
2023-07-21 19:40:20 +03:00
Extends the OpenAPI [Schema Object ](https://redocly.com/docs/openapi-visual-reference/schemas/ )
2017-03-09 13:55:23 +03:00
2023-11-09 18:56:30 +03:00
### x-nullable
| Field Name | Type | Description |
2016-08-31 22:45:34 +03:00
| :------------- | :------: | :---------- |
| x-nullable | boolean | marks schema as a nullable |
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2023-07-21 19:40:20 +03:00
Schemas marked as `x-nullable` are marked in Redoc with the label Nullable.
2017-02-26 03:17:22 +03:00
2023-11-09 18:56:30 +03:00
### x-extendedDiscriminator
2022-02-09 15:18:16 +03:00
**ATTENTION**: This is a Redoc-specific vendor extension, and is not supported by other tools.
2017-02-26 03:17:22 +03:00
2023-11-09 18:56:30 +03:00
| Field Name | Type | Description |
2017-02-26 03:17:22 +03:00
| :------------- | :------: | :---------- |
| x-extendedDiscriminator | string | specifies extended discriminator |
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2022-02-09 15:18:16 +03:00
Redoc uses this vendor extension to solve name-clash issues with the standard `discriminator` .
2023-07-11 20:31:52 +03:00
Value of this field specifies the field which is used as an extended discriminator.
2022-02-09 15:18:16 +03:00
Redoc displays definition with selectpicker using which user can select value of the `x-extendedDiscriminator` -marked field.
Redoc displays the definition derived from the current (using `allOf` ) and has `enum` with only one value which is the same as the selected value of the field specified as `x-extendedDiscriminator` .
2017-02-26 03:17:22 +03:00
2023-11-09 18:56:30 +03:00
#### x-extendedDiscriminator example
2017-02-26 03:17:22 +03:00
```yaml
Payment:
x-extendedDiscriminator: type
type: object
required:
- type
properties:
type:
type: string
name:
type: string
CashPayment:
allOf:
- $ref: "#/definitions/Payment"
- properties:
type:
type: string
enum:
- cash
currency:
type: string
PayPalPayment:
allOf:
- $ref: "#/definitions/Payment"
- properties:
type:
type: string
enum:
- paypal
userEmail:
type: string
```
2020-10-13 14:55:45 +03:00
In the example above, the names of definitions (`PayPalPayment`) are named differently than names in the payload (`paypal`) which is not supported by default `discriminator` .
2019-06-18 11:41:48 +03:00
2023-11-09 18:56:30 +03:00
### x-additionalPropertiesName
**Attention**: This is a Redoc-specific vendor extension, and is not supported by other tools.
2019-06-18 11:41:48 +03:00
Extends the `additionalProperties` property of the schema object.
2023-11-09 18:56:30 +03:00
| Field Name | Type | Description |
2019-06-18 11:41:48 +03:00
| :------------- | :------: | :---------- |
| x-additionalPropertiesName | string | descriptive name of additional properties keys |
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2022-02-09 15:18:16 +03:00
Redoc uses this extension to display a more descriptive property name in objects with `additionalProperties` when viewing the property list with an `object` .
2019-06-18 11:41:48 +03:00
2023-11-09 18:56:30 +03:00
#### x-additionalPropertiesName example
2019-06-18 11:41:48 +03:00
```yaml
Player:
required:
- name
properties:
name:
type: string
additionalProperties:
x-additionalPropertiesName: attribute-name
type: string
```
2020-03-27 13:09:44 +03:00
2023-11-09 18:56:30 +03:00
### x-explicitMappingOnly
**Attention**: This is Redoc-specific vendor extension, and is not supported by other tools.
2020-03-27 13:09:44 +03:00
Extends the `discriminator` property of the schema object.
2023-11-09 18:56:30 +03:00
| Field Name | Type | Description |
2020-03-27 13:09:44 +03:00
| :------------- | :------: | :---------- |
| x-explicitMappingOnly | boolean | limit the discriminator selectpicker to the explicit mappings only |
2023-11-09 18:56:30 +03:00
#### How to use with Redoc
2022-02-09 15:18:16 +03:00
Redoc uses this extension to filter the `discriminator` mappings shown in the selectpicker.
2023-07-11 20:31:52 +03:00
When set to `true` , the selectpicker lists only the explicitly defined mappings. When `false` , the default behavior is kept, in other words, explicit and implicit mappings are shown.
2020-03-27 13:09:44 +03:00
2023-11-09 18:56:30 +03:00
#### x-explicitMappingOnly example
2020-03-27 13:09:44 +03:00
```yaml
Pet:
type: object
required:
- name
- photoUrls
discriminator:
propertyName: petType
x-explicitMappingOnly: true
mapping:
cat: "#/components/schemas/Cat"
bee: "#/components/schemas/HoneyBee"
```
2023-07-11 20:31:52 +03:00
Shows in the selectpicker only the items `cat` and `bee` , even though the `Dog` class inherits from the `Pet` class.