mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +03:00
* Add x-additionalPropertiesName (#622) Supply custom name to be displayed for property name of `additionalProperties`. * Include prettier output for Schema.ts
This commit is contained in:
parent
c488bbf305
commit
0eb1e66a10
|
@ -218,6 +218,7 @@ ReDoc makes use of the following [vendor extensions](https://swagger.io/specific
|
|||
* [`x-tagGroups`](docs/redoc-vendor-extensions.md#x-tagGroups) - group tags by categories in the side menu
|
||||
* [`x-servers`](docs/redoc-vendor-extensions.md#x-servers) - ability to specify different servers for API (backported from OpenAPI 3.0)
|
||||
* [`x-ignoredHeaderParameters`](docs/redoc-vendor-extensions.md#x-ignoredHeaderParameters) - ability to specify header parameter names to ignore
|
||||
* [`x-additionalPropertiesName`](docs/redoc-vendor-extensions.md#x-additionalPropertiesName) - ability to supply a descriptive name for the additional property keys
|
||||
|
||||
### `<redoc>` options object
|
||||
You can use all of the following options with standalone version on <redoc> tag by kebab-casing them, e.g. `scrollYOffset` becomes `scroll-y-offset` and `expandResponses` becomes `expand-responses`.
|
||||
|
|
|
@ -278,3 +278,31 @@ PayPalPayment:
|
|||
|
||||
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`.
|
||||
|
||||
#### x-additionalPropertiesName
|
||||
**ATTENTION**: This is ReDoc-specific vendor extension. It won't be supported by other tools.
|
||||
|
||||
Extends the `additionalProperties` property of the schema object.
|
||||
|
||||
| Field Name | Type | Description |
|
||||
| :------------- | :------: | :---------- |
|
||||
| x-additionalPropertiesName | string | descriptive name of additional properties keys |
|
||||
|
||||
###### Usage in ReDoc
|
||||
ReDoc uses this extension to display a more descriptive property name in objects with `additionalProperties` when viewing the property list with an `object`.
|
||||
|
||||
###### x-additionalPropertiesName example
|
||||
|
||||
```yaml
|
||||
Player:
|
||||
required:
|
||||
- name
|
||||
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
|
||||
additionalProperties:
|
||||
x-additionalPropertiesName: attribute-name
|
||||
type: string
|
||||
```
|
||||
|
|
|
@ -292,7 +292,10 @@ function buildFields(
|
|||
new FieldModel(
|
||||
parser,
|
||||
{
|
||||
name: 'property name *',
|
||||
name: (typeof additionalProps === 'object'
|
||||
? additionalProps['x-additionalPropertiesName'] || 'property name'
|
||||
: 'property name'
|
||||
).concat('*'),
|
||||
required: false,
|
||||
schema: additionalProps === true ? {} : additionalProps,
|
||||
kind: 'additionalProperties',
|
||||
|
|
|
@ -423,6 +423,7 @@ export function isRedocExtension(key: string): boolean {
|
|||
'x-servers': true,
|
||||
'x-tagGroups': true,
|
||||
'x-traitTag': true,
|
||||
'x-additionalPropertiesName': true,
|
||||
};
|
||||
|
||||
return key in redocExtensions;
|
||||
|
|
Loading…
Reference in New Issue
Block a user