Skip to content

Commit 77b2328

Browse files
committed
fix: add more excluded headers and remove collector interface
1 parent 6d279fb commit 77b2328

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

src/APICollector.interface.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/APICollector.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import qs from 'qs';
33
import contentType from 'content-type';
44
import type { OpenAPIV3_1 } from 'openapi-types';
55
import type { ServerResponseArg, ObjectForResBodyBufferItem } from './types/asyncEventTypes';
6-
import type { API_URL, APICollectorInterface } from './APICollector.interface';
6+
import type { API_URL } from './types/apiTypes';
77

8-
export default class APICollector implements APICollectorInterface {
8+
export default class APICollector {
99
private items: Record<API_URL, OpenAPIV3_1.PathItemObject>;
1010

1111
constructor () {
@@ -82,7 +82,15 @@ export default class APICollector implements APICollectorInterface {
8282
}
8383

8484
private extractHeaders (serverRes: ServerResponseArg): Array<OpenAPIV3_1.ParameterObject> {
85-
const excludeHeaders = ['host', 'user-agent', 'content-length', 'content-type', 'accept'];
85+
const excludeHeaders = [
86+
'host',
87+
'user-agent',
88+
'content-length',
89+
'content-type',
90+
'accept',
91+
'connection',
92+
'accept-encoding'
93+
];
8694
const headers = this.genHeaderObjFromRawHeaders(
8795
serverRes.req.rawHeaders,
8896
{ exclude: excludeHeaders }

src/APIGenerator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import path from 'path';
33
import YAML from 'json-to-pretty-yaml';
44

55
import type { OpenAPIV3_1 } from 'openapi-types';
6-
import type { API_URL, APICollectorInterface } from './APICollector.interface';
6+
import type { API_URL } from './types/apiTypes';
7+
import type APICollector from './APICollector';
78

89
type GenDocOpts = {
910
output?: string,
@@ -16,7 +17,7 @@ const SUPPORTED_FORMAT = ['.json', '.yaml'];
1617

1718
export default class APIGenerator {
1819
public static async generate (
19-
apiCollector: APICollectorInterface,
20+
apiCollector: APICollector,
2021
opts: GenDocOpts
2122
): Promise<void> {
2223
const apiItems = apiCollector.getItems();

src/RequestHook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ObjectForResBodyBufferItem,
77
ServerResponseArg
88
} from './types/asyncEventTypes';
9-
import type { APICollectorInterface } from './APICollector.interface';
9+
import type APICollector from './APICollector';
1010

1111
/**
1212
* The response body data comes before ServerResponse event
@@ -99,7 +99,7 @@ export default class RequestHook {
9999
`;
100100
}
101101

102-
constructor (private apiCollector: APICollectorInterface) {
102+
constructor (private apiCollector: APICollector) {
103103
this.eventMap = {};
104104
}
105105

src/types/apiTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type API_URL = string

0 commit comments

Comments
 (0)