Skip to content

Commit

Permalink
feat: add ignoredHeaderParameters option
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Sep 21, 2017
1 parent 9aac636 commit 56d62e5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 22 additions & 1 deletion docs/redoc-vendor-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 21 additions & 11 deletions lib/components/ParamsList/params-list.ts
Original file line number Diff line number Diff line change
@@ -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] = [];
Expand All @@ -12,28 +13,37 @@ 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);
}

init() {
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 comment has been minimized.

Copy link
@adamaltman

adamaltman Aug 19, 2021

Member

Typo here

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);

Expand Down
4 changes: 3 additions & 1 deletion lib/services/options.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const OPTION_NAMES = new Set([
'noAutoAuth',
'pathInMiddlePanel',
'untrustedSpec',
'hideLoading'
'hideLoading',
'ignoredHeaderParameters',
]);

export interface Options {
Expand All @@ -38,6 +39,7 @@ export interface Options {
untrustedSpec?: boolean;
hideLoading?: boolean;
spec?: any;
ignoredHeaderParameters?: string[];
}

@Injectable()
Expand Down

0 comments on commit 56d62e5

Please sign in to comment.