mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
feat: add ignoredHeaderParameters option
This commit is contained in:
parent
9aac636687
commit
56d62e5ab2
|
@ -138,6 +138,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica
|
|||
* [`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
|
||||
* [`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
|
||||
|
||||
### `<redoc>` tag attributes
|
||||
* `spec-url` - relative or absolute url to your spec file;
|
||||
|
|
|
@ -54,7 +54,28 @@ x-tagGroups:
|
|||
- Secondary Stats
|
||||
```
|
||||
|
||||
#### <a name="logoObject"></a>Logo Object
|
||||
#### x-ignoredHeaderParameters
|
||||
|
||||
|
||||
| Field Name | Type | Description |
|
||||
| :-------------------------- | :-----------: | :---------- |
|
||||
| x-ignoredHeaderParameters | [ string ] | A list of ignored headers |
|
||||
|
||||
|
||||
###### Usage in Redoc
|
||||
`x-ignoredHeaderParameters` is used to specify header parameter names which are ignored by ReDoc
|
||||
|
||||
###### x-ignoredHeaderParameters example
|
||||
```yaml
|
||||
swagger: '2.0'
|
||||
info:
|
||||
...
|
||||
tags: [...]
|
||||
x-ignoredHeaderParameters:
|
||||
- Accept
|
||||
- User-Agent
|
||||
- X-Test-Header
|
||||
```
|
||||
|
||||
### Info Object vendor extensions
|
||||
Extends OpenAPI [Info Object](http://swagger.io/specification/#infoObject)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
'use strict';
|
||||
import { Component, Input, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
||||
import { BaseComponent, SpecManager } from '../base';
|
||||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
import { OptionsService } from '../../services/options.service';
|
||||
import { SchemaHelper } from '../../services/schema-helper.service';
|
||||
import { BaseComponent, SpecManager } from '../base';
|
||||
|
||||
function safePush(obj, prop, item) {
|
||||
if (!obj[prop]) obj[prop] = [];
|
||||
|
@ -12,16 +13,16 @@ function safePush(obj, prop, item) {
|
|||
selector: 'params-list',
|
||||
templateUrl: './params-list.html',
|
||||
styleUrls: ['./params-list.css'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class ParamsList extends BaseComponent implements OnInit {
|
||||
@Input() pointer:string;
|
||||
@Input() pointer: string;
|
||||
|
||||
params: Array<any>;
|
||||
empty: boolean;
|
||||
bodyParam: any;
|
||||
|
||||
constructor(specMgr:SpecManager) {
|
||||
constructor(specMgr: SpecManager, private options: OptionsService) {
|
||||
super(specMgr);
|
||||
}
|
||||
|
||||
|
@ -29,11 +30,20 @@ export class ParamsList extends BaseComponent implements OnInit {
|
|||
this.params = [];
|
||||
let paramsList = this.specMgr.getOperationParams(this.pointer);
|
||||
|
||||
paramsList = paramsList.map(paramSchema => {
|
||||
let propPointer = paramSchema._pointer;
|
||||
if (paramSchema.in === 'body') return paramSchema;
|
||||
return SchemaHelper.preprocess(paramSchema, propPointer, this.pointer);
|
||||
});
|
||||
const igrnoredHeaders =
|
||||
this.specMgr.schema['x-ignoredHeaderParameters'] ||
|
||||
this.options.options.ignoredHeaderParameters ||
|
||||
[];
|
||||
|
||||
paramsList = paramsList
|
||||
.map(paramSchema => {
|
||||
let propPointer = paramSchema._pointer;
|
||||
if (paramSchema.in === 'body') return paramSchema;
|
||||
return SchemaHelper.preprocess(paramSchema, propPointer, this.pointer);
|
||||
})
|
||||
.filter(param => {
|
||||
return param.in !== 'header' || igrnoredHeaders.indexOf(param.name) < 0;
|
||||
});
|
||||
|
||||
let paramsMap = this.orderParams(paramsList);
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ const OPTION_NAMES = new Set([
|
|||
'noAutoAuth',
|
||||
'pathInMiddlePanel',
|
||||
'untrustedSpec',
|
||||
'hideLoading'
|
||||
'hideLoading',
|
||||
'ignoredHeaderParameters',
|
||||
]);
|
||||
|
||||
export interface Options {
|
||||
|
@ -38,6 +39,7 @@ export interface Options {
|
|||
untrustedSpec?: boolean;
|
||||
hideLoading?: boolean;
|
||||
spec?: any;
|
||||
ignoredHeaderParameters?: string[];
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
|
Loading…
Reference in New Issue
Block a user