Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ClientProject
Redoc
Commits
becc2f58
Unverified
Commit
becc2f58
authored
5 years ago
by
Roman Hotsiy
Browse files
Options
Download
Email Patches
Plain Diff
fix: depreacate x-code-samples, rename to x-codeSamples for consistency
parent
6e607b9a
main
dependabot/npm_and_yarn/webpack-5.76.0
feat/sideNavStyle-idonly
oneof-perf-fix
redoc-cli
2.0.0-rc.69
v2.0.0
v2.0.0-rc.77
v2.0.0-rc.76
v2.0.0-rc.75
v2.0.0-rc.74
v2.0.0-rc.73
v2.0.0-rc.72
v2.0.0-rc.71
v2.0.0-rc.70
v2.0.0-rc.69
v2.0.0-rc.68.1
v2.0.0-rc.68
v2.0.0-rc.67
v2.0.0-rc.66
v2.0.0-rc.65
v2.0.0-rc.64
v2.0.0-rc.63
v2.0.0-rc.62
v2.0.0-rc.61
v2.0.0-rc.60
v2.0.0-rc.59
v2.0.0-rc.58
v2.0.0-rc.57
v2.0.0-rc.56
v2.0.0-rc.55
v2.0.0-rc.54
v2.0.0-rc.53
v2.0.0-rc.52
v2.0.0-rc.51
v2.0.0-rc.50
v2.0.0-rc.49
v2.0.0-rc.48
v2.0.0-rc.47
v2.0.0-rc.46
v2.0.0-rc.45
v2.0.0-rc.44
v2.0.0-rc.43
v2.0.0-rc.42
v2.0.0-rc.41
v2.0.0-rc.40
v2.0.0-rc.39
v2.0.0-rc.38
v2.0.0-rc.37
v2.0.0-rc.36
v2.0.0-rc.35
v2.0.0-rc.34
v2.0.0-rc.33
v2.0.0-rc.32
v2.0.0-rc.31
v2.0.0-rc.30
v2.0.0-rc.29
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
README.md
+1
-1
README.md
demo/openapi.yaml
+3
-3
demo/openapi.yaml
docs/redoc-vendor-extensions.md
+3
-3
docs/redoc-vendor-extensions.md
src/services/models/Operation.ts
+8
-1
src/services/models/Operation.ts
src/types/open-api.d.ts
+2
-1
src/types/open-api.d.ts
src/utils/openapi.ts
+2
-1
src/utils/openapi.ts
with
19 additions
and
10 deletions
+19
-10
README.md
View file @
becc2f58
...
...
@@ -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
)
:
*
[
`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
-s
amples`
](
docs/redoc-vendor-extensions.md#x-code
-s
amples
)
- specify operation code samples
*
[
`x-code
S
amples`
](
docs/redoc-vendor-extensions.md#x-code
S
amples
)
- 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#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
...
...
This diff is collapsed.
Click to expand it.
demo/openapi.yaml
View file @
becc2f58
...
...
@@ -114,7 +114,7 @@ paths:
-
petstore_auth
:
-
'
write:pets'
-
'
read:pets'
x-code
-s
amples
:
x-code
S
amples
:
-
lang
:
'
C#'
source
:
|
PetStore.v1.Pet pet = new PetStore.v1.Pet();
...
...
@@ -162,7 +162,7 @@ paths:
-
petstore_auth
:
-
'
write:pets'
-
'
read:pets'
x-code
-s
amples
:
x-code
S
amples
:
-
lang
:
PHP
source
:
|
$form = new \PetStore\Entities\Pet();
...
...
@@ -587,7 +587,7 @@ paths:
description
:
Response for cancelling subscription
'
500'
:
description
:
Callback processing failed and retries will be performed
x-code
-s
amples
:
x-code
S
amples
:
-
lang
:
'
C#'
source
:
|
PetStore.v1.Pet pet = new PetStore.v1.Pet();
...
...
This diff is collapsed.
Click to expand it.
docs/redoc-vendor-extensions.md
View file @
becc2f58
...
...
@@ -162,13 +162,13 @@ x-traitTag: true
### Operation Object vendor extensions
Extends OpenAPI
[
Operation Object
](
http://swagger.io/specification/#operationObject
)
#### x-code
-s
amples
#### x-code
S
amples
| Field Name | Type | Description |
| :------------- | :------: | :---------- |
| x-code
-s
amples |
[
[Code Sample Object
](
#codeSampleObject
)
] | A list of code samples associated with operation |
| x-code
S
amples |
[
[Code Sample Object
](
#codeSampleObject
)
] | A list of code samples associated with operation |
###### Usage in ReDoc
`x-code
-s
amples`
are rendered on the right panel of ReDoc
`x-code
S
amples`
are rendered on the right panel of ReDoc
#### <a name="codeSampleObject"></a>Code Sample Object
Operation code sample
...
...
This diff is collapsed.
Click to expand it.
src/services/models/Operation.ts
View file @
becc2f58
...
...
@@ -39,6 +39,8 @@ export function isPayloadSample(
return
sample
.
lang
===
'
payload
'
&&
(
sample
as
any
).
requestBodyContent
;
}
let
isCodeSamplesWarningPrinted
=
false
;
/**
* Operation model ready to be used by components
*/
...
...
@@ -173,7 +175,12 @@ export class OperationModel implements IMenuItem {
@
memoize
get
codeSamples
()
{
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
;
if
(
requestBodyContent
&&
requestBodyContent
.
hasSample
)
{
...
...
This diff is collapsed.
Click to expand it.
src/types/open-api.d.ts
View file @
becc2f58
...
...
@@ -76,7 +76,8 @@ export interface OpenAPIOperation {
deprecated
?:
boolean
;
security
?:
OpenAPISecurityRequirement
[];
servers
?:
OpenAPIServer
[];
'
x-code-samples
'
?:
OpenAPIXCodeSample
[];
'
x-codeSamples
'
?:
OpenAPIXCodeSample
[];
'
x-code-samples
'
?:
OpenAPIXCodeSample
[];
// deprecated
}
export
interface
OpenAPIParameter
{
...
...
This diff is collapsed.
Click to expand it.
src/utils/openapi.ts
View file @
becc2f58
...
...
@@ -569,7 +569,8 @@ export const shortenHTTPVerb = verb =>
export
function
isRedocExtension
(
key
:
string
):
boolean
{
const
redocExtensions
=
{
'
x-circular-ref
'
:
true
,
'
x-code-samples
'
:
true
,
'
x-code-samples
'
:
true
,
// deprecated
'
x-codeSamples
'
:
true
,
'
x-displayName
'
:
true
,
'
x-examples
'
:
true
,
'
x-ignoredHeaderParameters
'
:
true
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help