mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
fix: depreacate x-code-samples, rename to x-codeSamples for consistency
This commit is contained in:
parent
6e607b9a29
commit
becc2f5856
|
@ -211,7 +211,7 @@ You can inject Security Definitions widget into any place of your specification
|
||||||
ReDoc makes use of the following [vendor extensions](https://swagger.io/specification/#specificationExtensions):
|
ReDoc makes use of the following [vendor extensions](https://swagger.io/specification/#specificationExtensions):
|
||||||
* [`x-logo`](docs/redoc-vendor-extensions.md#x-logo) - is used to specify API logo
|
* [`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-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-codeSamples`](docs/redoc-vendor-extensions.md#x-codeSamples) - specify operation code samples
|
||||||
* [`x-examples`](docs/redoc-vendor-extensions.md#x-examples) - specify JSON example for requests
|
* [`x-examples`](docs/redoc-vendor-extensions.md#x-examples) - specify JSON example for requests
|
||||||
* [`x-nullable`](docs/redoc-vendor-extensions.md#x-nullable) - mark schema param as a nullable
|
* [`x-nullable`](docs/redoc-vendor-extensions.md#x-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-displayName`](docs/redoc-vendor-extensions.md#x-displayname) - specify human-friendly names for the menu categories
|
||||||
|
|
|
@ -114,7 +114,7 @@ paths:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- 'write:pets'
|
- 'write:pets'
|
||||||
- 'read:pets'
|
- 'read:pets'
|
||||||
x-code-samples:
|
x-codeSamples:
|
||||||
- lang: 'C#'
|
- lang: 'C#'
|
||||||
source: |
|
source: |
|
||||||
PetStore.v1.Pet pet = new PetStore.v1.Pet();
|
PetStore.v1.Pet pet = new PetStore.v1.Pet();
|
||||||
|
@ -162,7 +162,7 @@ paths:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- 'write:pets'
|
- 'write:pets'
|
||||||
- 'read:pets'
|
- 'read:pets'
|
||||||
x-code-samples:
|
x-codeSamples:
|
||||||
- lang: PHP
|
- lang: PHP
|
||||||
source: |
|
source: |
|
||||||
$form = new \PetStore\Entities\Pet();
|
$form = new \PetStore\Entities\Pet();
|
||||||
|
@ -587,7 +587,7 @@ paths:
|
||||||
description: Response for cancelling subscription
|
description: Response for cancelling subscription
|
||||||
'500':
|
'500':
|
||||||
description: Callback processing failed and retries will be performed
|
description: Callback processing failed and retries will be performed
|
||||||
x-code-samples:
|
x-codeSamples:
|
||||||
- lang: 'C#'
|
- lang: 'C#'
|
||||||
source: |
|
source: |
|
||||||
PetStore.v1.Pet pet = new PetStore.v1.Pet();
|
PetStore.v1.Pet pet = new PetStore.v1.Pet();
|
||||||
|
|
|
@ -162,13 +162,13 @@ x-traitTag: true
|
||||||
|
|
||||||
### Operation Object vendor extensions
|
### Operation Object vendor extensions
|
||||||
Extends OpenAPI [Operation Object](http://swagger.io/specification/#operationObject)
|
Extends OpenAPI [Operation Object](http://swagger.io/specification/#operationObject)
|
||||||
#### x-code-samples
|
#### x-codeSamples
|
||||||
| Field Name | Type | Description |
|
| Field Name | Type | Description |
|
||||||
| :------------- | :------: | :---------- |
|
| :------------- | :------: | :---------- |
|
||||||
| x-code-samples | [ [Code Sample Object](#codeSampleObject) ] | A list of code samples associated with operation |
|
| x-codeSamples | [ [Code Sample Object](#codeSampleObject) ] | A list of code samples associated with operation |
|
||||||
|
|
||||||
###### Usage in ReDoc
|
###### Usage in ReDoc
|
||||||
`x-code-samples` are rendered on the right panel of ReDoc
|
`x-codeSamples` are rendered on the right panel of ReDoc
|
||||||
|
|
||||||
#### <a name="codeSampleObject"></a>Code Sample Object
|
#### <a name="codeSampleObject"></a>Code Sample Object
|
||||||
Operation code sample
|
Operation code sample
|
||||||
|
|
|
@ -39,6 +39,8 @@ export function isPayloadSample(
|
||||||
return sample.lang === 'payload' && (sample as any).requestBodyContent;
|
return sample.lang === 'payload' && (sample as any).requestBodyContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isCodeSamplesWarningPrinted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation model ready to be used by components
|
* Operation model ready to be used by components
|
||||||
*/
|
*/
|
||||||
|
@ -173,7 +175,12 @@ export class OperationModel implements IMenuItem {
|
||||||
@memoize
|
@memoize
|
||||||
get codeSamples() {
|
get codeSamples() {
|
||||||
let samples: Array<OpenAPIXCodeSample | XPayloadSample> =
|
let samples: Array<OpenAPIXCodeSample | XPayloadSample> =
|
||||||
this.operationSpec['x-code-samples'] || [];
|
this.operationSpec['x-codeSamples'] || this.operationSpec['x-code-samples'] || [];
|
||||||
|
|
||||||
|
if (this.operationSpec['x-code-samples'] && !isCodeSamplesWarningPrinted) {
|
||||||
|
isCodeSamplesWarningPrinted = true;
|
||||||
|
console.warn('"x-code-samples" is deprecated. Use "x-codeSamples" instead');
|
||||||
|
}
|
||||||
|
|
||||||
const requestBodyContent = this.requestBody && this.requestBody.content;
|
const requestBodyContent = this.requestBody && this.requestBody.content;
|
||||||
if (requestBodyContent && requestBodyContent.hasSample) {
|
if (requestBodyContent && requestBodyContent.hasSample) {
|
||||||
|
|
3
src/types/open-api.d.ts
vendored
3
src/types/open-api.d.ts
vendored
|
@ -76,7 +76,8 @@ export interface OpenAPIOperation {
|
||||||
deprecated?: boolean;
|
deprecated?: boolean;
|
||||||
security?: OpenAPISecurityRequirement[];
|
security?: OpenAPISecurityRequirement[];
|
||||||
servers?: OpenAPIServer[];
|
servers?: OpenAPIServer[];
|
||||||
'x-code-samples'?: OpenAPIXCodeSample[];
|
'x-codeSamples'?: OpenAPIXCodeSample[];
|
||||||
|
'x-code-samples'?: OpenAPIXCodeSample[]; // deprecated
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenAPIParameter {
|
export interface OpenAPIParameter {
|
||||||
|
|
|
@ -569,7 +569,8 @@ export const shortenHTTPVerb = verb =>
|
||||||
export function isRedocExtension(key: string): boolean {
|
export function isRedocExtension(key: string): boolean {
|
||||||
const redocExtensions = {
|
const redocExtensions = {
|
||||||
'x-circular-ref': true,
|
'x-circular-ref': true,
|
||||||
'x-code-samples': true,
|
'x-code-samples': true, // deprecated
|
||||||
|
'x-codeSamples': true,
|
||||||
'x-displayName': true,
|
'x-displayName': true,
|
||||||
'x-examples': true,
|
'x-examples': true,
|
||||||
'x-ignoredHeaderParameters': true,
|
'x-ignoredHeaderParameters': true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user