redoc/docs/redoc-vendor-extensions.md

177 lines
5.1 KiB
Markdown
Raw Normal View History

2016-02-01 20:23:13 +03:00
# ReDoc vendor extensions
ReDoc makes use of the following [vendor extensions](http://swagger.io/specification/#vendorExtensions)
2016-12-26 00:47:33 +03:00
### Swagger Object vendor extensions
Extend OpenAPI root [Swagger Object](http://swagger.io/specification/#swaggerObject)
#### x-tagGroups
| Field Name | Type | Description |
| :------------- | :-----------: | :---------- |
| x-tagGroups | [ [Tag Group Object](#tagGroupObject) ] | A list of tag groups |
###### Usage in Redoc
`x-tagGroups` is used to group tags in the side menu
#### <a name="tagGroupObject"></a>Tag Group Object
Information about tags group
###### Fixed fields
| Field Name | Type | Description |
| :---------- | :--------: | :---------- |
| name | string | The group name |
| tags | [ string ] | List of tags to include in this group
###### x-tagGroups example
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
```
#### <a name="logoObject"></a>Logo Object
2016-07-17 21:48:56 +03:00
### Info Object vendor extensions
Extends OpenAPI [Info Object](http://swagger.io/specification/#infoObject)
2016-07-17 19:02:27 +03:00
#### x-logo
2016-02-01 20:38:21 +03:00
| Field Name | Type | Description |
| :------------- | :-----------: | :---------- |
| x-logo | [Logo Object](#logoObject) | The information about API logo |
2016-02-01 20:23:13 +03:00
2016-02-01 20:49:57 +03:00
###### Usage in Redoc
2016-02-01 20:23:13 +03:00
`x-logo` is used to specify API logo. The corresponding image are displayed just above side-menu.
2016-02-01 20:49:57 +03:00
#### <a name="logoObject"></a>Logo Object
2016-02-01 20:23:13 +03:00
The information about API logo
2016-02-01 20:49:57 +03:00
###### Fixed fields
2016-02-01 20:38:21 +03:00
| Field Name | Type | Description |
| :-------------- | :------: | :---------- |
| url | string | The URL pointing to the spec logo. MUST be in the format of a URL
| backgroundColor | string | background color to be used. MUST be RGB color in [hexadecimal format] (https://en.wikipedia.org/wiki/Web_colors#Hex_triplet)
2016-02-01 20:23:13 +03:00
2016-02-01 20:49:57 +03:00
###### x-logo example
json
```json
2016-02-01 20:23:13 +03:00
{
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"x-logo": {
"url": "https://rebilly.github.io/ReDoc/petstore-logo.png",
2016-04-22 16:33:27 +03:00
"backgroundColor": "#FFFFFF"
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:
url: "https://rebilly.github.io/ReDoc/petstore-logo.png"
2016-04-22 16:33:27 +03:00
backgroundColor: "#FFFFFF"
2016-02-01 20:23:13 +03:00
```
2016-07-17 21:48:56 +03:00
### Tag Object vendor extensions
Extends OpenAPI [Tag Object](http://swagger.io/specification/#tagObject)
2016-10-31 13:32:03 +03:00
#### x-traitTag [DEPRECATED]
2016-02-01 20:38:21 +03:00
| Field Name | Type | Description |
| :------------- | :------: | :---------- |
| x-traitTag | boolean | In Swagger two operations can have multiply tags. This property distinguish 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
#### x-displayName
| Field Name | Type | Description |
| :------------- | :------: | :---------- |
| x-displayName | string | Define the text that is used for this tag in the menu and in section headings |
2016-02-01 20:49:57 +03:00
###### Usage in Redoc
2016-02-01 20:23:13 +03:00
Tags that have `x-traitTag` set to `true` are listed in side-menu but don't have any subitems (operations). Tag `description` is rendered as well.
This is useful for handling out common things like Pagination, Rate-Limits, etc.
2016-02-01 20:49:57 +03:00
###### x-traitTag example
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
```
2016-07-17 21:48:56 +03:00
### Operation Object vendor extensions
Extends OpenAPI [Operation Object](http://swagger.io/specification/#operationObject)
2016-07-17 19:02:27 +03:00
#### x-code-samples
2016-02-01 20:38:21 +03:00
| Field Name | Type | Description |
| :------------- | :------: | :---------- |
2016-02-01 20:49:57 +03:00
| x-code-samples | [ [Code Sample Object](#codeSampleObject) ] | A list of code samples associated with operation |
2016-02-01 20:23:13 +03:00
2016-02-01 20:49:57 +03:00
###### Usage in ReDoc
`x-code-samples` are rendered on the right panel of ReDoc
2016-02-01 20:23:13 +03:00
2016-02-01 20:49:57 +03:00
#### <a name="codeSampleObject"></a>Code Sample Object
2016-02-01 20:23:13 +03:00
Operation code sample
2016-02-01 20:49:57 +03:00
###### Fixed fields
2016-02-01 20:38:21 +03:00
| Field Name | Type | Description |
| :---------- | :------: | :----------- |
| lang | string | Code sample language. Value should be one of the following [list](https://github.com/github/linguist/blob/master/lib/linguist/popular.yml) |
| source | string | Code sample source code |
2016-02-01 20:23:13 +03:00
2016-02-01 20:49:57 +03:00
###### Code Sample Object example
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
### Schema Object vendor extensions
Extends OpenAPI [Schema Object](http://swagger.io/specification/#schemaObject)
2016-12-08 12:40:00 +03:00
#### x-nullable
2016-08-31 22:45:34 +03:00
| Field Name | Type | Description |
| :------------- | :------: | :---------- |
| x-nullable | boolean | marks schema as a nullable |
###### Usage in ReDoc
Schemas marked as `x-nullable` are marked in ReDoc with the label Nullable