mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 01:54:08 +03:00
Support x-examples vendor extension for requests
This commit is contained in:
parent
9ccfd52640
commit
3c569cde6e
|
@ -123,6 +123,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica
|
|||
* [`x-logo`](docs/redoc-vendor-extensions.md#x-logo) - is used to specify API logo
|
||||
* [`x-traitTag`](docs/redoc-vendor-extensions.md#x-traitTag) - useful for handling out common things like Pagination, Rate-Limits, etc
|
||||
* [`x-code-samples`](docs/redoc-vendor-extensions.md#x-code-samples) - specify operation code samples
|
||||
* [`x-examples`](docs/redoc-vendor-extensions.md#x-examples) - specify JSON example for requests
|
||||
* [`x-nullable`](docs/redoc-vendor-extensions.md#nullable) - mark schema param as a nullable
|
||||
* [`x-displayName`](docs/redoc-vendor-extensions.md#x-displayname) - specify human-friendly names for the menu categories
|
||||
* [`x-tagGroups`](docs/redoc-vendor-extensions.md#x-tagGroups) - group tags by categories in the side menu
|
||||
|
|
|
@ -169,6 +169,17 @@ lang: JavaScript
|
|||
source: console.log('Hello World');
|
||||
```
|
||||
|
||||
### Parameter Object vendor extensions
|
||||
Extends OpenAPI [Parameter Object](http://swagger.io/specification/#parameterObject)
|
||||
#### x-examples
|
||||
| Field Name | Type | Description |
|
||||
| :------------- | :------: | :---------- |
|
||||
| x-examples | [Example Object](http://swagger.io/specification/#exampleObject) | Object that contains examples for the request. Applies when `in` is `body` and mime-type is `application/json` |
|
||||
|
||||
###### Usage in ReDoc
|
||||
`x-examples` are rendered in the JSON tab on the right panel of ReDoc.
|
||||
|
||||
|
||||
### Schema Object vendor extensions
|
||||
Extends OpenAPI [Schema Object](http://swagger.io/specification/#schemaObject)
|
||||
#### x-nullable
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import { Component, ElementRef, Input, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
||||
|
||||
import * as OpenAPISampler from 'openapi-sampler';
|
||||
|
||||
import JsonPointer from '../../utils/JsonPointer';
|
||||
import { BaseComponent, SpecManager } from '../base';
|
||||
import { SchemaNormalizer } from '../../services/schema-normalizer.service';
|
||||
|
||||
|
@ -42,6 +42,13 @@ export class SchemaSample extends BaseComponent implements OnInit {
|
|||
this.pointer += '/schema';
|
||||
}
|
||||
|
||||
// Support x-examples, allowing requests to specify an example.
|
||||
let examplePointer:string = JsonPointer.join(JsonPointer.dirName(this.pointer), 'x-examples');
|
||||
let requestExamples:any = this.specMgr.byPointer(examplePointer);
|
||||
if (requestExamples) {
|
||||
base.examples = requestExamples;
|
||||
}
|
||||
|
||||
if (base.examples && base.examples['application/json']) {
|
||||
sample = base.examples['application/json'];
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user