@ehuelsmann/openapi-validator 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/classes/AbstractOpenApiSpec.d.ts +47 -0
- package/dist/classes/AbstractOpenApiSpec.d.ts.map +1 -0
- package/dist/classes/AbstractOpenApiSpec.js +149 -0
- package/dist/classes/AbstractOpenApiSpec.js.map +1 -0
- package/dist/classes/AbstractResponse.d.ts +23 -0
- package/dist/classes/AbstractResponse.d.ts.map +1 -0
- package/dist/classes/AbstractResponse.js +18 -0
- package/dist/classes/AbstractResponse.js.map +1 -0
- package/dist/classes/AxiosResponse.d.ts +9 -0
- package/dist/classes/AxiosResponse.d.ts.map +1 -0
- package/dist/classes/AxiosResponse.js +24 -0
- package/dist/classes/AxiosResponse.js.map +1 -0
- package/dist/classes/OpenApi2Spec.d.ts +19 -0
- package/dist/classes/OpenApi2Spec.d.ts.map +1 -0
- package/dist/classes/OpenApi2Spec.js +81 -0
- package/dist/classes/OpenApi2Spec.js.map +1 -0
- package/dist/classes/OpenApi3Spec.d.ts +24 -0
- package/dist/classes/OpenApi3Spec.d.ts.map +1 -0
- package/dist/classes/OpenApi3Spec.js +99 -0
- package/dist/classes/OpenApi3Spec.js.map +1 -0
- package/dist/classes/RequestPromiseResponse.d.ts +14 -0
- package/dist/classes/RequestPromiseResponse.d.ts.map +1 -0
- package/dist/classes/RequestPromiseResponse.js +34 -0
- package/dist/classes/RequestPromiseResponse.js.map +1 -0
- package/dist/classes/SuperAgentResponse.d.ts +17 -0
- package/dist/classes/SuperAgentResponse.d.ts.map +1 -0
- package/dist/classes/SuperAgentResponse.js +37 -0
- package/dist/classes/SuperAgentResponse.js.map +1 -0
- package/dist/classes/errors/ValidationError.d.ts +15 -0
- package/dist/classes/errors/ValidationError.d.ts.map +1 -0
- package/dist/classes/errors/ValidationError.js +24 -0
- package/dist/classes/errors/ValidationError.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/openApiSpecFactory.d.ts +5 -0
- package/dist/openApiSpecFactory.d.ts.map +1 -0
- package/dist/openApiSpecFactory.js +67 -0
- package/dist/openApiSpecFactory.js.map +1 -0
- package/dist/responseFactory.d.ts +6 -0
- package/dist/responseFactory.d.ts.map +1 -0
- package/dist/responseFactory.js +19 -0
- package/dist/responseFactory.js.map +1 -0
- package/dist/utils/OpenApi3Spec.utils.d.ts +7 -0
- package/dist/utils/OpenApi3Spec.utils.d.ts.map +1 -0
- package/dist/utils/OpenApi3Spec.utils.js +54 -0
- package/dist/utils/OpenApi3Spec.utils.js.map +1 -0
- package/dist/utils/common.utils.d.ts +10 -0
- package/dist/utils/common.utils.d.ts.map +1 -0
- package/dist/utils/common.utils.js +58 -0
- package/dist/utils/common.utils.js.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# OpenAPI Validator
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ehuelsmann/openapi-validator)
|
|
4
|
+
[](https://www.npmjs.com/package/@ehuelsmann/openapi-validator)
|
|
5
|
+
|
|
6
|
+
Common code for [@ehuelsmann/jest-openapi](https://www.npmjs.com/package/@ehuelsmann/jest-openapi) and [Chai OpenAPI Response Validator](https://www.npmjs.com/package/@ehuelsmann/chai-openapi-response-validator)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import type { ActualRequest, ActualResponse } from './AbstractResponse';
|
|
3
|
+
import ValidationError from './errors/ValidationError';
|
|
4
|
+
type Document = OpenAPIV2.Document | OpenAPIV3.Document;
|
|
5
|
+
type Operation = OpenAPIV2.OperationObject | OpenAPIV3.OperationObject;
|
|
6
|
+
type PathItemObject = OpenAPIV2.PathItemObject | OpenAPIV3.PathItemObject;
|
|
7
|
+
export type ResponseObjectWithSchema = (OpenAPIV2.ResponseObject & {
|
|
8
|
+
schema: OpenAPIV2.Schema;
|
|
9
|
+
}) | (OpenAPIV3.ResponseObject & {
|
|
10
|
+
content: {
|
|
11
|
+
[media: string]: OpenAPIV3.MediaTypeObject & {
|
|
12
|
+
schema: OpenAPIV3.SchemaObject;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}) | (OpenAPIV3_1.ResponseObject & {
|
|
16
|
+
content: {
|
|
17
|
+
[media: string]: OpenAPIV3_1.MediaTypeObject & {
|
|
18
|
+
schema: OpenAPIV3_1.SchemaObject;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
export type Schema = OpenAPIV2.Schema | OpenAPIV3.SchemaObject;
|
|
23
|
+
export default abstract class OpenApiSpec {
|
|
24
|
+
protected spec: Document;
|
|
25
|
+
protected abstract getSchemaObjects(): Record<string, Schema> | undefined;
|
|
26
|
+
protected abstract findResponseDefinition(referenceString: string): ResponseObjectWithSchema | undefined;
|
|
27
|
+
protected abstract findOpenApiPathMatchingPathname(pathname: string): string;
|
|
28
|
+
protected abstract getComponentDefinitionsProperty(): {
|
|
29
|
+
definitions: OpenAPIV2.Document['definitions'];
|
|
30
|
+
} | {
|
|
31
|
+
components: OpenAPIV3.Document['components'];
|
|
32
|
+
};
|
|
33
|
+
constructor(spec: Document);
|
|
34
|
+
pathsObject(): Document['paths'];
|
|
35
|
+
getPathItem(openApiPath: string): PathItemObject;
|
|
36
|
+
paths(): string[];
|
|
37
|
+
getSchemaObject(schemaName: string): Schema | undefined;
|
|
38
|
+
getExpectedResponse(responseOperation: Operation, status: ActualResponse['status']): ResponseObjectWithSchema | undefined;
|
|
39
|
+
findExpectedResponse(actualResponse: ActualResponse): Record<string, ResponseObjectWithSchema>;
|
|
40
|
+
findOpenApiPathMatchingRequest(actualRequest: ActualRequest): string;
|
|
41
|
+
findExpectedPathItem(actualRequest: ActualRequest): PathItemObject;
|
|
42
|
+
findExpectedResponseOperation(actualRequest: ActualRequest): Operation | undefined;
|
|
43
|
+
validateResponse(actualResponse: ActualResponse): ValidationError | null;
|
|
44
|
+
validateObject(actualObject: unknown, schema: Schema): ValidationError | null;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=AbstractOpenApiSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractOpenApiSpec.d.ts","sourceRoot":"","sources":["../../lib/classes/AbstractOpenApiSpec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,eAA8B,MAAM,0BAA0B,CAAC;AAEtE,KAAK,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AAExD,KAAK,SAAS,GAAG,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AAIvE,KAAK,cAAc,GAAG,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,cAAc,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAChC,CAAC,SAAS,CAAC,cAAc,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,GACzD,CAAC,SAAS,CAAC,cAAc,GAAG;IAC1B,OAAO,EAAE;QACP,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,eAAe,GAAG;YAC3C,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC;SAChC,CAAC;KACH,CAAC;CACH,CAAC,GACF,CAAC,WAAW,CAAC,cAAc,GAAG;IAC5B,OAAO,EAAE;QACP,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,eAAe,GAAG;YAC7C,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC;SACl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AG,SAAS;IAOxB,gBAAgB,CAAC,cAAc,EAAE,cAAc,GAAG,eAAe,GAAG,IAAI;IAuCxE,cAAc,CACZ,YAAY,EAAE,OAAO,EACrB,MAAM,EAAE,MAAM,GACb,eAAe,GAAG,IAAI;CAsB1B"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const openapi_response_validator_1 = __importDefault(require("openapi-response-validator"));
|
|
40
|
+
const common_utils_1 = require("../utils/common.utils");
|
|
41
|
+
const ValidationError_1 = __importStar(require("./errors/ValidationError"));
|
|
42
|
+
class OpenApiSpec {
|
|
43
|
+
constructor(spec) {
|
|
44
|
+
this.spec = spec;
|
|
45
|
+
}
|
|
46
|
+
pathsObject() {
|
|
47
|
+
return this.spec.paths;
|
|
48
|
+
}
|
|
49
|
+
getPathItem(openApiPath) {
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
51
|
+
return this.pathsObject()[openApiPath];
|
|
52
|
+
}
|
|
53
|
+
paths() {
|
|
54
|
+
return Object.keys(this.pathsObject());
|
|
55
|
+
}
|
|
56
|
+
getSchemaObject(schemaName) {
|
|
57
|
+
var _a;
|
|
58
|
+
return (_a = this.getSchemaObjects()) === null || _a === void 0 ? void 0 : _a[schemaName];
|
|
59
|
+
}
|
|
60
|
+
getExpectedResponse(responseOperation, status) {
|
|
61
|
+
const response = responseOperation.responses[status];
|
|
62
|
+
if (!response) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if ('$ref' in response) {
|
|
66
|
+
return this.findResponseDefinition(response.$ref);
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
findExpectedResponse(actualResponse) {
|
|
71
|
+
const actualRequest = actualResponse.req;
|
|
72
|
+
const expectedResponseOperation = this.findExpectedResponseOperation(actualRequest);
|
|
73
|
+
if (!expectedResponseOperation) {
|
|
74
|
+
throw new ValidationError_1.default(ValidationError_1.ErrorCode.MethodNotFound);
|
|
75
|
+
}
|
|
76
|
+
const { status } = actualResponse;
|
|
77
|
+
const expectedResponse = this.getExpectedResponse(expectedResponseOperation, status);
|
|
78
|
+
if (!expectedResponse) {
|
|
79
|
+
throw new ValidationError_1.default(ValidationError_1.ErrorCode.StatusNotFound);
|
|
80
|
+
}
|
|
81
|
+
return { [status]: expectedResponse };
|
|
82
|
+
}
|
|
83
|
+
findOpenApiPathMatchingRequest(actualRequest) {
|
|
84
|
+
const actualPathname = (0, common_utils_1.getPathname)(actualRequest);
|
|
85
|
+
const openApiPath = this.findOpenApiPathMatchingPathname(actualPathname);
|
|
86
|
+
return openApiPath;
|
|
87
|
+
}
|
|
88
|
+
findExpectedPathItem(actualRequest) {
|
|
89
|
+
const actualPathname = (0, common_utils_1.getPathname)(actualRequest);
|
|
90
|
+
const openApiPath = this.findOpenApiPathMatchingPathname(actualPathname);
|
|
91
|
+
const pathItemObject = this.getPathItem(openApiPath);
|
|
92
|
+
return pathItemObject;
|
|
93
|
+
}
|
|
94
|
+
findExpectedResponseOperation(actualRequest) {
|
|
95
|
+
const pathItemObject = this.findExpectedPathItem(actualRequest);
|
|
96
|
+
const operationObject = pathItemObject[actualRequest.method.toLowerCase()];
|
|
97
|
+
return operationObject;
|
|
98
|
+
}
|
|
99
|
+
validateResponse(actualResponse) {
|
|
100
|
+
let expectedResponse;
|
|
101
|
+
try {
|
|
102
|
+
expectedResponse = this.findExpectedResponse(actualResponse);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error instanceof ValidationError_1.default) {
|
|
106
|
+
return error;
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
const validator = new openapi_response_validator_1.default({
|
|
111
|
+
responses: expectedResponse,
|
|
112
|
+
...this.getComponentDefinitionsProperty(),
|
|
113
|
+
});
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
|
+
const expectedResStatus = Object.keys(expectedResponse)[0];
|
|
116
|
+
const validationError = validator.validateResponse(expectedResStatus, actualResponse.getBodyForValidation());
|
|
117
|
+
return validationError
|
|
118
|
+
? new ValidationError_1.default(ValidationError_1.ErrorCode.InvalidBody, validationError.errors
|
|
119
|
+
.map(({ path, message }) => `${path} ${message}`)
|
|
120
|
+
.join(', '))
|
|
121
|
+
: null;
|
|
122
|
+
}
|
|
123
|
+
/*
|
|
124
|
+
* For consistency and to save maintaining another dependency,
|
|
125
|
+
* we validate objects using our response validator:
|
|
126
|
+
* We put the object inside a mock response, then validate
|
|
127
|
+
* the whole response against a mock expected response.
|
|
128
|
+
* The 2 mock responses are identical except for the body,
|
|
129
|
+
* thus validating the object against its schema.
|
|
130
|
+
*/
|
|
131
|
+
validateObject(actualObject, schema) {
|
|
132
|
+
const mockResStatus = '200';
|
|
133
|
+
const mockExpectedResponse = { [mockResStatus]: { schema } };
|
|
134
|
+
const validator = new openapi_response_validator_1.default({
|
|
135
|
+
responses: mockExpectedResponse,
|
|
136
|
+
...this.getComponentDefinitionsProperty(),
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
138
|
+
errorTransformer: ({ path, message }) => ({
|
|
139
|
+
message: `${path.replace('response', 'object')} ${message}`,
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
const validationError = validator.validateResponse(mockResStatus, actualObject);
|
|
143
|
+
return validationError
|
|
144
|
+
? new ValidationError_1.default(ValidationError_1.ErrorCode.InvalidObject, validationError.errors.map((error) => error.message).join(', '))
|
|
145
|
+
: null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.default = OpenApiSpec;
|
|
149
|
+
//# sourceMappingURL=AbstractOpenApiSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractOpenApiSpec.js","sourceRoot":"","sources":["../../lib/classes/AbstractOpenApiSpec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4FAEoC;AAEpC,wDAAoD;AA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,CAAC,CAAC,KAA0B,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACtF;YACH,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;CACF;AA9JD,8BA8JC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RawAxiosResponse } from './AxiosResponse';
|
|
2
|
+
import type { RawRequestPromiseResponse } from './RequestPromiseResponse';
|
|
3
|
+
import type { RawSuperAgentResponse } from './SuperAgentResponse';
|
|
4
|
+
export type RawResponse = RawAxiosResponse | RawSuperAgentResponse | RawRequestPromiseResponse;
|
|
5
|
+
export default abstract class AbstractResponse {
|
|
6
|
+
protected res: RawResponse;
|
|
7
|
+
status: number;
|
|
8
|
+
req: {
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
abstract getBodyForValidation(): unknown;
|
|
13
|
+
protected body: unknown;
|
|
14
|
+
protected bodyHasNoContent: boolean;
|
|
15
|
+
constructor(res: RawResponse);
|
|
16
|
+
summary(): {
|
|
17
|
+
body: unknown;
|
|
18
|
+
};
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
export type ActualResponse = AbstractResponse;
|
|
22
|
+
export type ActualRequest = AbstractResponse['req'];
|
|
23
|
+
//# sourceMappingURL=AbstractResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractResponse.d.ts","sourceRoot":"","sources":["../../lib/classes/AbstractResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,qBAAqB,GACrB,yBAAyB,CAAC;AAE9B,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAgB;IAWhC,SAAS,CAAC,GAAG,EAAE,WAAW;IAVvB,MAAM,EAAE,MAAM,CAAC;IAEf,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;aAErC,oBAAoB,IAAI,OAAO;IAE/C,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;IAExB,UAAkB,gBAAgB,EAAE,OAAO,CAAC;gBAEtB,GAAG,EAAE,WAAW;IAEtC,OAAO,IAAI;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE;IAM5B,QAAQ,IAAI,MAAM;CAGnB;AAED,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_utils_1 = require("../utils/common.utils");
|
|
4
|
+
class AbstractResponse {
|
|
5
|
+
constructor(res) {
|
|
6
|
+
this.res = res;
|
|
7
|
+
}
|
|
8
|
+
summary() {
|
|
9
|
+
return {
|
|
10
|
+
body: this.body,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return (0, common_utils_1.stringify)(this.summary());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = AbstractResponse;
|
|
18
|
+
//# sourceMappingURL=AbstractResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractResponse.js","sourceRoot":"","sources":["../../lib/classes/AbstractResponse.ts"],"names":[],"mappings":";;AAAA,wDAAkD;AAUlD,MAA8B,gBAAgB;IAW5C,YAAsB,GAAgB;QAAhB,QAAG,GAAH,GAAG,CAAa;IAAG,CAAC;IAE1C,OAAO;QACL,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAA,wBAAS,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACnC,CAAC;CACF;AAtBD,mCAsBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AxiosResponse as AxiosResponseType } from 'axios';
|
|
2
|
+
import AbstractResponse from './AbstractResponse';
|
|
3
|
+
export type RawAxiosResponse = AxiosResponseType;
|
|
4
|
+
export default class AxiosResponse extends AbstractResponse {
|
|
5
|
+
protected res: RawAxiosResponse;
|
|
6
|
+
constructor(res: RawAxiosResponse);
|
|
7
|
+
getBodyForValidation(): AxiosResponse['body'];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=AxiosResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxiosResponse.d.ts","sourceRoot":"","sources":["../../lib/classes/AxiosResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,gBAAgB;cAC1B,GAAG,EAAE,gBAAgB;gBAArB,GAAG,EAAE,gBAAgB;IAQpD,oBAAoB,IAAI,aAAa,CAAC,MAAM,CAAC;CAM9C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const AbstractResponse_1 = __importDefault(require("./AbstractResponse"));
|
|
7
|
+
class AxiosResponse extends AbstractResponse_1.default {
|
|
8
|
+
constructor(res) {
|
|
9
|
+
super(res);
|
|
10
|
+
this.res = res;
|
|
11
|
+
this.status = res.status;
|
|
12
|
+
this.body = res.data;
|
|
13
|
+
this.req = res.request;
|
|
14
|
+
this.bodyHasNoContent = this.body === '';
|
|
15
|
+
}
|
|
16
|
+
getBodyForValidation() {
|
|
17
|
+
if (this.bodyHasNoContent) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return this.body;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = AxiosResponse;
|
|
24
|
+
//# sourceMappingURL=AxiosResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxiosResponse.js","sourceRoot":"","sources":["../../lib/classes/AxiosResponse.ts"],"names":[],"mappings":";;;;;AACA,0EAAkD;AAIlD,MAAqB,aAAc,SAAQ,0BAAgB;IACzD,YAA+B,GAAqB;QAClD,KAAK,CAAC,GAAG,CAAC,CAAC;QADkB,QAAG,GAAH,GAAG,CAAkB;QAElD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AAfD,gCAeC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OpenAPIV2 } from 'openapi-types';
|
|
2
|
+
import type { ResponseObjectWithSchema } from './AbstractOpenApiSpec';
|
|
3
|
+
import AbstractOpenApiSpec from './AbstractOpenApiSpec';
|
|
4
|
+
export default class OpenApi2Spec extends AbstractOpenApiSpec {
|
|
5
|
+
spec: OpenAPIV2.Document;
|
|
6
|
+
didUserDefineBasePath: boolean;
|
|
7
|
+
constructor(spec: OpenAPIV2.Document);
|
|
8
|
+
/**
|
|
9
|
+
* "If the basePath property is not provided, the API is served directly under the host
|
|
10
|
+
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#fixed-fields
|
|
11
|
+
*/
|
|
12
|
+
findOpenApiPathMatchingPathname(pathname: string): string;
|
|
13
|
+
findResponseDefinition(referenceString: string): ResponseObjectWithSchema | undefined;
|
|
14
|
+
getComponentDefinitionsProperty(): {
|
|
15
|
+
definitions: OpenAPIV2.Document['definitions'];
|
|
16
|
+
};
|
|
17
|
+
getSchemaObjects(): OpenAPIV2.Document['definitions'];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=OpenApi2Spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApi2Spec.d.ts","sourceRoot":"","sources":["../../lib/classes/OpenApi2Spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAKtE,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAMxD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,mBAAmB;IAG/B,IAAI,EAAE,SAAS,CAAC,QAAQ;IAF7C,qBAAqB,EAAE,OAAO,CAAC;gBAEV,IAAI,EAAE,SAAS,CAAC,QAAQ;IAKpD;;;OAGG;IACH,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAkBzD,sBAAsB,CACpB,eAAe,EAAE,MAAM,GACtB,wBAAwB,GAAG,SAAS;IAQvC,+BAA+B,IAAI;QACjC,WAAW,EAAE,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;KAChD;IAID,gBAAgB,IAAI,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC;CAGtD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const common_utils_1 = require("../utils/common.utils");
|
|
40
|
+
const AbstractOpenApiSpec_1 = __importDefault(require("./AbstractOpenApiSpec"));
|
|
41
|
+
const ValidationError_1 = __importStar(require("./errors/ValidationError"));
|
|
42
|
+
const basePathPropertyNotProvided = (spec) => !spec.basePath;
|
|
43
|
+
class OpenApi2Spec extends AbstractOpenApiSpec_1.default {
|
|
44
|
+
constructor(spec) {
|
|
45
|
+
super(spec);
|
|
46
|
+
this.spec = spec;
|
|
47
|
+
this.didUserDefineBasePath = !basePathPropertyNotProvided(spec);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* "If the basePath property is not provided, the API is served directly under the host
|
|
51
|
+
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#fixed-fields
|
|
52
|
+
*/
|
|
53
|
+
findOpenApiPathMatchingPathname(pathname) {
|
|
54
|
+
const { basePath } = this.spec;
|
|
55
|
+
if (basePath && !pathname.startsWith(basePath)) {
|
|
56
|
+
throw new ValidationError_1.default(ValidationError_1.ErrorCode.BasePathNotFound);
|
|
57
|
+
}
|
|
58
|
+
const pathnameWithoutBasePath = basePath
|
|
59
|
+
? (0, common_utils_1.getPathnameWithoutBasePath)(basePath, pathname)
|
|
60
|
+
: pathname;
|
|
61
|
+
const openApiPath = (0, common_utils_1.findOpenApiPathMatchingPossiblePathnames)([pathnameWithoutBasePath], this.paths());
|
|
62
|
+
if (!openApiPath) {
|
|
63
|
+
throw new ValidationError_1.default(ValidationError_1.ErrorCode.PathNotFound);
|
|
64
|
+
}
|
|
65
|
+
return openApiPath;
|
|
66
|
+
}
|
|
67
|
+
findResponseDefinition(referenceString) {
|
|
68
|
+
var _a;
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
70
|
+
const nameOfResponseDefinition = referenceString.split('#/responses/')[1];
|
|
71
|
+
return (_a = this.spec.responses) === null || _a === void 0 ? void 0 : _a[nameOfResponseDefinition];
|
|
72
|
+
}
|
|
73
|
+
getComponentDefinitionsProperty() {
|
|
74
|
+
return { definitions: this.spec.definitions };
|
|
75
|
+
}
|
|
76
|
+
getSchemaObjects() {
|
|
77
|
+
return this.spec.definitions;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = OpenApi2Spec;
|
|
81
|
+
//# sourceMappingURL=OpenApi2Spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApi2Spec.js","sourceRoot":"","sources":["../../lib/classes/OpenApi2Spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wDAG+B;AAC/B,gFAAwD;AACxD,4EAAsE;AAEtE,MAAM,2BAA2B,GAAG,CAAC,IAAwB,EAAW,EAAE,CACxE,CAAC,IAAI,CAAC,QAAQ,CAAC;AAEjB,MAAqB,YAAa,SAAQ,6BAAmB;IAG3D,YAA4B,IAAwB;QAClD,KAAK,CAAC,IAAI,CAAC,CAAC;QADc,SAAI,GAAJ,IAAI,CAAoB;QAElD,IAAI,CAAC,qBAAqB,GAAG,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;OAGG;IACH,+BAA+B,CAAC,QAAgB;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QAC/B,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,yBAAe,CAAC,2BAAS,CAAC,gBAAgB,CAAC,CAAC;QACxD,CAAC;QACD,MAAM,uBAAuB,GAAG,QAAQ;YACtC,CAAC,CAAC,IAAA,yCAA0B,EAAC,QAAQ,EAAE,QAAQ,CAAC;YAChD,CAAC,CAAC,QAAQ,CAAC;QACb,MAAM,WAAW,GAAG,IAAA,uDAAwC,EAC1D,CAAC,uBAAuB,CAAC,EACzB,IAAI,CAAC,KAAK,EAAE,CACb,CAAC;QACF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,yBAAe,CAAC,2BAAS,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,sBAAsB,CACpB,eAAuB;;QAEvB,oEAAoE;QACpE,MAAM,wBAAwB,GAAG,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAE,CAAC;QAC3E,OAAO,MAAA,IAAI,CAAC,IAAI,CAAC,SAAS,0CAAG,wBAAwB,CAExC,CAAC;IAChB,CAAC;IAED,+BAA+B;QAG7B,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAChD,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;IAC/B,CAAC;CACF;AAjDD,+BAiDC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import type { ResponseObjectWithSchema } from './AbstractOpenApiSpec';
|
|
3
|
+
import AbstractOpenApiSpec from './AbstractOpenApiSpec';
|
|
4
|
+
export default class OpenApi3Spec extends AbstractOpenApiSpec {
|
|
5
|
+
protected spec: OpenAPIV3.Document;
|
|
6
|
+
didUserDefineServers: boolean;
|
|
7
|
+
constructor(spec: OpenAPIV3.Document);
|
|
8
|
+
/**
|
|
9
|
+
* "If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of '/'"
|
|
10
|
+
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#fixed-fields
|
|
11
|
+
*/
|
|
12
|
+
ensureDefaultServer(): void;
|
|
13
|
+
servers(): OpenAPIV3.ServerObject[];
|
|
14
|
+
getServerUrls(): string[];
|
|
15
|
+
getMatchingServerUrls(pathname: string): string[];
|
|
16
|
+
getMatchingServerBasePaths(pathname: string): string[];
|
|
17
|
+
findOpenApiPathMatchingPathname(pathname: string): string;
|
|
18
|
+
findResponseDefinition(referenceString: string): ResponseObjectWithSchema | undefined;
|
|
19
|
+
getComponentDefinitionsProperty(): {
|
|
20
|
+
components: OpenAPIV3.Document['components'];
|
|
21
|
+
};
|
|
22
|
+
getSchemaObjects(): OpenAPIV3.ComponentsObject['schemas'];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=OpenApi3Spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApi3Spec.d.ts","sourceRoot":"","sources":["../../lib/classes/OpenApi3Spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAUtE,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAGxD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,mBAAmB;cAG5B,IAAI,EAAE,SAAS,CAAC,QAAQ;IAFhD,oBAAoB,EAAE,OAAO,CAAC;gBAEN,IAAI,EAAE,SAAS,CAAC,QAAQ;IAMvD;;;OAGG;IACH,mBAAmB,IAAI,IAAI;IAM3B,OAAO,IAAI,SAAS,CAAC,YAAY,EAAE;IAKnC,aAAa,IAAI,MAAM,EAAE;IAIzB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAOjD,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAOtD,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAkBzD,sBAAsB,CACpB,eAAe,EAAE,MAAM,GACtB,wBAAwB,GAAG,SAAS;IAUvC,+BAA+B,IAAI;QACjC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;KAC9C;IAID,gBAAgB,IAAI,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC;CAG1D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const common_utils_1 = require("../utils/common.utils");
|
|
40
|
+
const OpenApi3Spec_utils_1 = require("../utils/OpenApi3Spec.utils");
|
|
41
|
+
const AbstractOpenApiSpec_1 = __importDefault(require("./AbstractOpenApiSpec"));
|
|
42
|
+
const ValidationError_1 = __importStar(require("./errors/ValidationError"));
|
|
43
|
+
class OpenApi3Spec extends AbstractOpenApiSpec_1.default {
|
|
44
|
+
constructor(spec) {
|
|
45
|
+
super(spec);
|
|
46
|
+
this.spec = spec;
|
|
47
|
+
this.didUserDefineServers = !(0, OpenApi3Spec_utils_1.serversPropertyNotProvidedOrIsEmptyArray)(spec);
|
|
48
|
+
this.ensureDefaultServer();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* "If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of '/'"
|
|
52
|
+
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#fixed-fields
|
|
53
|
+
*/
|
|
54
|
+
ensureDefaultServer() {
|
|
55
|
+
if ((0, OpenApi3Spec_utils_1.serversPropertyNotProvidedOrIsEmptyArray)(this.spec)) {
|
|
56
|
+
this.spec.servers = [{ url: common_utils_1.defaultBasePath }];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
servers() {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
+
return this.spec.servers;
|
|
62
|
+
}
|
|
63
|
+
getServerUrls() {
|
|
64
|
+
return this.servers().map((server) => server.url);
|
|
65
|
+
}
|
|
66
|
+
getMatchingServerUrls(pathname) {
|
|
67
|
+
return (0, OpenApi3Spec_utils_1.getMatchingServerUrlsAndServerBasePaths)(this.servers(), pathname).map(({ concreteUrl }) => concreteUrl);
|
|
68
|
+
}
|
|
69
|
+
getMatchingServerBasePaths(pathname) {
|
|
70
|
+
return (0, OpenApi3Spec_utils_1.getMatchingServerUrlsAndServerBasePaths)(this.servers(), pathname).map(({ matchingBasePath }) => matchingBasePath);
|
|
71
|
+
}
|
|
72
|
+
findOpenApiPathMatchingPathname(pathname) {
|
|
73
|
+
const matchingServerBasePaths = this.getMatchingServerBasePaths(pathname);
|
|
74
|
+
if (!matchingServerBasePaths.length) {
|
|
75
|
+
throw new ValidationError_1.default(ValidationError_1.ErrorCode.ServerNotFound);
|
|
76
|
+
}
|
|
77
|
+
const possiblePathnames = matchingServerBasePaths.map((basePath) => (0, common_utils_1.getPathnameWithoutBasePath)(basePath, pathname));
|
|
78
|
+
const openApiPath = (0, common_utils_1.findOpenApiPathMatchingPossiblePathnames)(possiblePathnames, this.paths());
|
|
79
|
+
if (!openApiPath) {
|
|
80
|
+
throw new ValidationError_1.default(ValidationError_1.ErrorCode.PathNotFound);
|
|
81
|
+
}
|
|
82
|
+
return openApiPath;
|
|
83
|
+
}
|
|
84
|
+
findResponseDefinition(referenceString) {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
87
|
+
const nameOfResponseDefinition = referenceString.split('#/components/responses/')[1];
|
|
88
|
+
return (_b = (_a = this.spec.components) === null || _a === void 0 ? void 0 : _a.responses) === null || _b === void 0 ? void 0 : _b[nameOfResponseDefinition];
|
|
89
|
+
}
|
|
90
|
+
getComponentDefinitionsProperty() {
|
|
91
|
+
return { components: this.spec.components };
|
|
92
|
+
}
|
|
93
|
+
getSchemaObjects() {
|
|
94
|
+
var _a;
|
|
95
|
+
return (_a = this.spec.components) === null || _a === void 0 ? void 0 : _a.schemas;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.default = OpenApi3Spec;
|
|
99
|
+
//# sourceMappingURL=OpenApi3Spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApi3Spec.js","sourceRoot":"","sources":["../../lib/classes/OpenApi3Spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA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AC1E,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,IAAI,yBAAe,CAAC,2BAAS,CAAC,cAAc,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACjE,IAAA,yCAA0B,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAC/C,CAAC;QACF,MAAM,WAAW,GAAG,IAAA,uDAAwC,EAC1D,iBAAiB,EACjB,IAAI,CAAC,KAAK,EAAE,CACb,CAAC;QACF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,yBAAe,CAAC,2BAAS,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,sBAAsB,CACpB,eAAuB;;QAEvB,oEAAoE;QACpE,MAAM,wBAAwB,GAAG,eAAe,CAAC,KAAK,CACpD,yBAAyB,CAC1B,CAAC,CAAC,CAAE,CAAC;QACN,OAAO,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,UAAU,0CAAE,SAAS,0CAAG,wBAAwB,CAEpD,CAAC;IAChB,CAAC;IAED,+BAA+B;QAG7B,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IAC9C,CAAC;IAED,gBAAgB;;QACd,OAAO,MAAA,IAAI,CAAC,IAAI,CAAC,UAAU,0CAAE,OAAO,CAAC;IACvC,CAAC;CACF;AAjFD,+BAiFC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Request, Response } from 'request';
|
|
2
|
+
import AbstractResponse from './AbstractResponse';
|
|
3
|
+
export type RawRequestPromiseResponse = Response & {
|
|
4
|
+
req: Request;
|
|
5
|
+
request: Response['request'] & {
|
|
6
|
+
_json?: unknown;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default class RequestPromiseResponse extends AbstractResponse {
|
|
10
|
+
protected res: RawRequestPromiseResponse;
|
|
11
|
+
constructor(res: RawRequestPromiseResponse);
|
|
12
|
+
getBodyForValidation(): RequestPromiseResponse['body'];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=RequestPromiseResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestPromiseResponse.d.ts","sourceRoot":"","sources":["../../lib/classes/RequestPromiseResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG;IACjD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG;QAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,gBAAgB;cACnC,GAAG,EAAE,yBAAyB;gBAA9B,GAAG,EAAE,yBAAyB;IAU7D,oBAAoB,IAAI,sBAAsB,CAAC,MAAM,CAAC;CAavD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const AbstractResponse_1 = __importDefault(require("./AbstractResponse"));
|
|
7
|
+
class RequestPromiseResponse extends AbstractResponse_1.default {
|
|
8
|
+
constructor(res) {
|
|
9
|
+
super(res);
|
|
10
|
+
this.res = res;
|
|
11
|
+
this.status = res.statusCode;
|
|
12
|
+
this.body = res.request._json // eslint-disable-line no-underscore-dangle
|
|
13
|
+
? res.body
|
|
14
|
+
: res.body.replace(/"/g, '');
|
|
15
|
+
this.req = res.req;
|
|
16
|
+
this.bodyHasNoContent = this.body === '';
|
|
17
|
+
}
|
|
18
|
+
getBodyForValidation() {
|
|
19
|
+
if (this.bodyHasNoContent) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return JSON.parse(this.body);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// if JSON.parse errors, then body is not stringfied JSON that
|
|
27
|
+
// needs parsing into a JSON object, so just move to the next
|
|
28
|
+
// block and return the body
|
|
29
|
+
}
|
|
30
|
+
return this.body;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = RequestPromiseResponse;
|
|
34
|
+
//# sourceMappingURL=RequestPromiseResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestPromiseResponse.js","sourceRoot":"","sources":["../../lib/classes/RequestPromiseResponse.ts"],"names":[],"mappings":";;;;;AACA,0EAAkD;AASlD,MAAqB,sBAAuB,SAAQ,0BAAgB;IAClE,YAA+B,GAA8B;QAC3D,KAAK,CAAC,GAAG,CAAC,CAAC;QADkB,QAAG,GAAH,GAAG,CAA2B;QAE3D,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,2CAA2C;YACvE,CAAC,CAAC,GAAG,CAAC,IAAI;YACV,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,8DAA8D;YAC9D,6DAA6D;YAC7D,4BAA4B;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AAxBD,yCAwBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Response, SuperAgentRequest } from 'superagent';
|
|
2
|
+
import AbstractResponse from './AbstractResponse';
|
|
3
|
+
export type RawSuperAgentResponse = Response & {
|
|
4
|
+
req: SuperAgentRequest & {
|
|
5
|
+
path: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export default class SuperAgentResponse extends AbstractResponse {
|
|
9
|
+
protected res: RawSuperAgentResponse;
|
|
10
|
+
private isResTextPopulatedInsteadOfResBody;
|
|
11
|
+
constructor(res: RawSuperAgentResponse);
|
|
12
|
+
getBodyForValidation(): SuperAgentResponse['body'];
|
|
13
|
+
summary(): ReturnType<AbstractResponse['summary']> & {
|
|
14
|
+
text?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SuperAgentResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuperAgentResponse.d.ts","sourceRoot":"","sources":["../../lib/classes/SuperAgentResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAMlD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG;IAC7C,GAAG,EAAE,iBAAiB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,gBAAgB;cAG/B,GAAG,EAAE,qBAAqB;IAFzD,OAAO,CAAC,kCAAkC,CAAU;gBAErB,GAAG,EAAE,qBAAqB;IAUzD,oBAAoB,IAAI,kBAAkB,CAAC,MAAM,CAAC;IAUzC,OAAO,IAAI,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAG;QAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;CAMF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const AbstractResponse_1 = __importDefault(require("./AbstractResponse"));
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
const isEmptyObj = (obj) => !!obj && Object.entries(obj).length === 0 && obj.constructor === Object;
|
|
9
|
+
class SuperAgentResponse extends AbstractResponse_1.default {
|
|
10
|
+
constructor(res) {
|
|
11
|
+
super(res);
|
|
12
|
+
this.res = res;
|
|
13
|
+
this.status = res.status;
|
|
14
|
+
this.body = res.body;
|
|
15
|
+
this.req = res.req;
|
|
16
|
+
this.isResTextPopulatedInsteadOfResBody =
|
|
17
|
+
res.text !== '{}' && isEmptyObj(this.body);
|
|
18
|
+
this.bodyHasNoContent = res.text === '';
|
|
19
|
+
}
|
|
20
|
+
getBodyForValidation() {
|
|
21
|
+
if (this.bodyHasNoContent) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (this.isResTextPopulatedInsteadOfResBody) {
|
|
25
|
+
return this.res.text;
|
|
26
|
+
}
|
|
27
|
+
return this.body;
|
|
28
|
+
}
|
|
29
|
+
summary() {
|
|
30
|
+
return {
|
|
31
|
+
...super.summary(),
|
|
32
|
+
...(this.isResTextPopulatedInsteadOfResBody && { text: this.res.text }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = SuperAgentResponse;
|
|
37
|
+
//# sourceMappingURL=SuperAgentResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuperAgentResponse.js","sourceRoot":"","sources":["../../lib/classes/SuperAgentResponse.ts"],"names":[],"mappings":";;;;;AACA,0EAAkD;AAElD,8DAA8D;AAC9D,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAgC,EAAE,CAC5D,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;AAM1E,MAAqB,kBAAmB,SAAQ,0BAAgB;IAG9D,YAA+B,GAA0B;QACvD,KAAK,CAAC,GAAG,CAAC,CAAC;QADkB,QAAG,GAAH,GAAG,CAAuB;QAEvD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;QACnB,IAAI,CAAC,kCAAkC;YACrC,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;IAC1C,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,IAAI,CAAC,kCAAkC,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEQ,OAAO;QAGd,OAAO;YACL,GAAG,KAAK,CAAC,OAAO,EAAE;YAClB,GAAG,CAAC,IAAI,CAAC,kCAAkC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxE,CAAC;IACJ,CAAC;CACF;AA/BD,qCA+BC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum ErrorCode {
|
|
2
|
+
ServerNotFound = 0,
|
|
3
|
+
BasePathNotFound = 1,
|
|
4
|
+
PathNotFound = 2,
|
|
5
|
+
MethodNotFound = 3,
|
|
6
|
+
StatusNotFound = 4,
|
|
7
|
+
InvalidBody = 5,
|
|
8
|
+
InvalidObject = 6
|
|
9
|
+
}
|
|
10
|
+
export default class ValidationError extends Error {
|
|
11
|
+
code: ErrorCode;
|
|
12
|
+
constructor(code: ErrorCode, message?: string);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ValidationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../../lib/classes/errors/ValidationError.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,cAAc,IAAA;IACd,gBAAgB,IAAA;IAChB,YAAY,IAAA;IACZ,cAAc,IAAA;IACd,cAAc,IAAA;IACd,WAAW,IAAA;IACX,aAAa,IAAA;CACd;AAED,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,KAAK;IAEvC,IAAI,EAAE,SAAS;gBAAf,IAAI,EAAE,SAAS,EACtB,OAAO,CAAC,EAAE,MAAM;IAKT,QAAQ,IAAI,MAAM;CAG5B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorCode = void 0;
|
|
4
|
+
var ErrorCode;
|
|
5
|
+
(function (ErrorCode) {
|
|
6
|
+
ErrorCode[ErrorCode["ServerNotFound"] = 0] = "ServerNotFound";
|
|
7
|
+
ErrorCode[ErrorCode["BasePathNotFound"] = 1] = "BasePathNotFound";
|
|
8
|
+
ErrorCode[ErrorCode["PathNotFound"] = 2] = "PathNotFound";
|
|
9
|
+
ErrorCode[ErrorCode["MethodNotFound"] = 3] = "MethodNotFound";
|
|
10
|
+
ErrorCode[ErrorCode["StatusNotFound"] = 4] = "StatusNotFound";
|
|
11
|
+
ErrorCode[ErrorCode["InvalidBody"] = 5] = "InvalidBody";
|
|
12
|
+
ErrorCode[ErrorCode["InvalidObject"] = 6] = "InvalidObject";
|
|
13
|
+
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
14
|
+
class ValidationError extends Error {
|
|
15
|
+
constructor(code, message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.code = code;
|
|
18
|
+
}
|
|
19
|
+
toString() {
|
|
20
|
+
return this.message;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = ValidationError;
|
|
24
|
+
//# sourceMappingURL=ValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../../lib/classes/errors/ValidationError.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,6DAAc,CAAA;IACd,iEAAgB,CAAA;IAChB,yDAAY,CAAA;IACZ,6DAAc,CAAA;IACd,6DAAc,CAAA;IACd,uDAAW,CAAA;IACX,2DAAa,CAAA;AACf,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB;AAED,MAAqB,eAAgB,SAAQ,KAAK;IAChD,YACS,IAAe,EACtB,OAAgB;QAEhB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAW;IAIxB,CAAC;IAEQ,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAXD,kCAWC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OpenAPI } from 'openapi-types';
|
|
2
|
+
import type OpenApi2Spec from './classes/OpenApi2Spec';
|
|
3
|
+
import type OpenApi3Spec from './classes/OpenApi3Spec';
|
|
4
|
+
export type { Schema } from './classes/AbstractOpenApiSpec';
|
|
5
|
+
export type { ActualRequest, ActualResponse, RawResponse, } from './classes/AbstractResponse';
|
|
6
|
+
export type { default as ValidationError } from './classes/errors/ValidationError';
|
|
7
|
+
export { ErrorCode } from './classes/errors/ValidationError';
|
|
8
|
+
export type { default as OpenApi2Spec } from './classes/OpenApi2Spec';
|
|
9
|
+
export type { default as OpenApi3Spec } from './classes/OpenApi3Spec';
|
|
10
|
+
export { default as makeApiSpec } from './openApiSpecFactory';
|
|
11
|
+
export { default as makeResponse } from './responseFactory';
|
|
12
|
+
export type OpenApiSpec = OpenApi2Spec | OpenApi3Spec;
|
|
13
|
+
export type OpenAPISpecObject = OpenAPI.Document;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAC;AAEvD,YAAY,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAC5D,YAAY,EACV,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtE,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AACtD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeResponse = exports.makeApiSpec = exports.ErrorCode = void 0;
|
|
7
|
+
var ValidationError_1 = require("./classes/errors/ValidationError");
|
|
8
|
+
Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return ValidationError_1.ErrorCode; } });
|
|
9
|
+
var openApiSpecFactory_1 = require("./openApiSpecFactory");
|
|
10
|
+
Object.defineProperty(exports, "makeApiSpec", { enumerable: true, get: function () { return __importDefault(openApiSpecFactory_1).default; } });
|
|
11
|
+
var responseFactory_1 = require("./responseFactory");
|
|
12
|
+
Object.defineProperty(exports, "makeResponse", { enumerable: true, get: function () { return __importDefault(responseFactory_1).default; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAWA,oEAA6D;AAApD,4GAAA,SAAS,OAAA;AAGlB,2DAA8D;AAArD,kIAAA,OAAO,OAAe;AAC/B,qDAA4D;AAAnD,gIAAA,OAAO,OAAgB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OpenAPI } from 'openapi-types';
|
|
2
|
+
import OpenApi2Spec from './classes/OpenApi2Spec';
|
|
3
|
+
import OpenApi3Spec from './classes/OpenApi3Spec';
|
|
4
|
+
export default function makeApiSpec(filepathOrObject: string | OpenAPI.Document): OpenApi2Spec | OpenApi3Spec;
|
|
5
|
+
//# sourceMappingURL=openApiSpecFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openApiSpecFactory.d.ts","sourceRoot":"","sources":["../lib/openApiSpecFactory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAwB,MAAM,eAAe,CAAC;AAGnE,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAQlD,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAC1C,YAAY,GAAG,YAAY,CAQ7B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = makeApiSpec;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
|
+
const openapi_schema_validator_1 = __importDefault(require("openapi-schema-validator"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const typeof_1 = __importDefault(require("typeof"));
|
|
12
|
+
const OpenApi2Spec_1 = __importDefault(require("./classes/OpenApi2Spec"));
|
|
13
|
+
const OpenApi3Spec_1 = __importDefault(require("./classes/OpenApi3Spec"));
|
|
14
|
+
const common_utils_1 = require("./utils/common.utils");
|
|
15
|
+
const isObject = (arg) => typeof arg === 'object' && arg !== null && !Array.isArray(arg);
|
|
16
|
+
function makeApiSpec(filepathOrObject) {
|
|
17
|
+
const spec = loadSpec(filepathOrObject);
|
|
18
|
+
validateSpec(spec);
|
|
19
|
+
const validSpec = spec;
|
|
20
|
+
if ('swagger' in validSpec) {
|
|
21
|
+
return new OpenApi2Spec_1.default(validSpec);
|
|
22
|
+
}
|
|
23
|
+
return new OpenApi3Spec_1.default(validSpec);
|
|
24
|
+
}
|
|
25
|
+
function loadSpec(arg) {
|
|
26
|
+
try {
|
|
27
|
+
if (typeof arg === 'string') {
|
|
28
|
+
return loadFile(arg);
|
|
29
|
+
}
|
|
30
|
+
if (isObject(arg)) {
|
|
31
|
+
return arg;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Received type '${(0, typeof_1.default)(arg)}'`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new Error(`The provided argument must be either an absolute filepath or an object representing an OpenAPI specification.\nError details: ${error.message}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function loadFile(filepath) {
|
|
40
|
+
if (!path_1.default.isAbsolute(filepath)) {
|
|
41
|
+
throw new Error(`'${filepath}' is not an absolute filepath`);
|
|
42
|
+
}
|
|
43
|
+
const fileData = fs_extra_1.default.readFileSync(filepath, { encoding: 'utf8' });
|
|
44
|
+
try {
|
|
45
|
+
return js_yaml_1.default.load(fileData);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new Error(`Invalid YAML or JSON:\n${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function validateSpec(obj) {
|
|
52
|
+
try {
|
|
53
|
+
const validator = new openapi_schema_validator_1.default({
|
|
54
|
+
version: obj.swagger || // '2.0'
|
|
55
|
+
obj.openapi, // '3.X.X'
|
|
56
|
+
});
|
|
57
|
+
const { errors } = validator.validate(obj);
|
|
58
|
+
if (errors.length > 0) {
|
|
59
|
+
throw new Error((0, common_utils_1.stringify)(errors));
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new Error(`Invalid OpenAPI spec: ${error.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=openApiSpecFactory.js.map
|
|
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;IAChC,IAAI,CAAC,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,IAAI,QAAQ,+BAA+B,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,QAAQ,GAAG,kBAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC;QACH,OAAO,iBAAI,CAAC,IAAI,CAAC,QAAQ,CAAc,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0BAA2B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAc;IAClC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,kCAAsB,CAAC;YAC3C,OAAO,EACJ,GAAqC,CAAC,OAAO,IAAI,QAAQ;gBACzD,GAAqC,CAAC,OAAO,EAAE,UAAU;SAC7D,CAAC,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAuB,CAAC,CAAC;QAC/D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,IAAA,wBAAS,EAAC,MAAM,CAAC,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,GAAuB,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,yBAA0B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RawResponse } from './classes/AbstractResponse';
|
|
2
|
+
import AxiosResponse from './classes/AxiosResponse';
|
|
3
|
+
import RequestPromiseResponse from './classes/RequestPromiseResponse';
|
|
4
|
+
import SuperAgentResponse from './classes/SuperAgentResponse';
|
|
5
|
+
export default function makeResponse(res: RawResponse): AxiosResponse | SuperAgentResponse | RequestPromiseResponse;
|
|
6
|
+
//# sourceMappingURL=responseFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseFactory.d.ts","sourceRoot":"","sources":["../lib/responseFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,sBAAsB,MAAM,kCAAkC,CAAC;AACtE,OAAO,kBAAkB,MAAM,8BAA8B,CAAC;AAE9D,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,GAAG,EAAE,WAAW,GACf,aAAa,GAAG,kBAAkB,GAAG,sBAAsB,CAQ7D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = makeResponse;
|
|
7
|
+
const AxiosResponse_1 = __importDefault(require("./classes/AxiosResponse"));
|
|
8
|
+
const RequestPromiseResponse_1 = __importDefault(require("./classes/RequestPromiseResponse"));
|
|
9
|
+
const SuperAgentResponse_1 = __importDefault(require("./classes/SuperAgentResponse"));
|
|
10
|
+
function makeResponse(res) {
|
|
11
|
+
if ('data' in res) {
|
|
12
|
+
return new AxiosResponse_1.default(res);
|
|
13
|
+
}
|
|
14
|
+
if ('status' in res) {
|
|
15
|
+
return new SuperAgentResponse_1.default(res);
|
|
16
|
+
}
|
|
17
|
+
return new RequestPromiseResponse_1.default(res);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=responseFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseFactory.js","sourceRoot":"","sources":["../lib/responseFactory.ts"],"names":[],"mappings":";;;;;AAKA,+BAUC;AAdD,4EAAoD;AACpD,8FAAsE;AACtE,sFAA8D;AAE9D,SAAwB,YAAY,CAClC,GAAgB;IAEhB,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAClB,OAAO,IAAI,uBAAa,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;QACpB,OAAO,IAAI,4BAAkB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,gCAAsB,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
export declare const serversPropertyNotProvidedOrIsEmptyArray: (spec: OpenAPIV3.Document) => boolean;
|
|
3
|
+
export declare const getMatchingServerUrlsAndServerBasePaths: (servers: OpenAPIV3.ServerObject[], pathname: string) => {
|
|
4
|
+
concreteUrl: string;
|
|
5
|
+
matchingBasePath: string;
|
|
6
|
+
}[];
|
|
7
|
+
//# sourceMappingURL=OpenApi3Spec.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApi3Spec.utils.d.ts","sourceRoot":"","sources":["../../lib/utils/OpenApi3Spec.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO/C,eAAO,MAAM,wCAAwC,GACnD,MAAM,SAAS,CAAC,QAAQ,KACvB,OAAgD,CAAC;AAmEpD,eAAO,MAAM,uCAAuC,GAClD,SAAS,SAAS,CAAC,YAAY,EAAE,EACjC,UAAU,MAAM,KACf;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,EAoBnD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMatchingServerUrlsAndServerBasePaths = exports.serversPropertyNotProvidedOrIsEmptyArray = void 0;
|
|
7
|
+
const combos_1 = __importDefault(require("combos"));
|
|
8
|
+
const common_utils_1 = require("./common.utils");
|
|
9
|
+
const unique = (array) => [...new Set(array)];
|
|
10
|
+
const serversPropertyNotProvidedOrIsEmptyArray = (spec) => !spec.servers || !spec.servers.length;
|
|
11
|
+
exports.serversPropertyNotProvidedOrIsEmptyArray = serversPropertyNotProvidedOrIsEmptyArray;
|
|
12
|
+
const getBasePath = (url) => {
|
|
13
|
+
const basePathStartIndex = url.replace('//', ' ').indexOf('/');
|
|
14
|
+
return basePathStartIndex !== -1
|
|
15
|
+
? url.slice(basePathStartIndex)
|
|
16
|
+
: common_utils_1.defaultBasePath;
|
|
17
|
+
};
|
|
18
|
+
const getPossibleValuesOfServerVariable = ({ default: defaultValue, enum: enumMembers, }) => enumMembers ? unique([defaultValue].concat(enumMembers)) : [defaultValue];
|
|
19
|
+
const mapServerVariablesToPossibleValues = (serverVariables) => Object.entries(serverVariables).reduce((currentMap, [variableName, detailsOfPossibleValues]) => ({
|
|
20
|
+
...currentMap,
|
|
21
|
+
[variableName]: getPossibleValuesOfServerVariable(detailsOfPossibleValues),
|
|
22
|
+
}), {});
|
|
23
|
+
const convertTemplateExpressionToConcreteExpression = (templateExpression, mapOfVariablesToValues) => Object.entries(mapOfVariablesToValues).reduce((currentExpression, [variable, value]) => currentExpression.replace(`{${variable}}`, value), templateExpression);
|
|
24
|
+
const getPossibleConcreteBasePaths = (basePath, serverVariables) => {
|
|
25
|
+
const mapOfServerVariablesToPossibleValues = mapServerVariablesToPossibleValues(serverVariables);
|
|
26
|
+
const combinationsOfBasePathVariableValues = (0, combos_1.default)(mapOfServerVariablesToPossibleValues);
|
|
27
|
+
const possibleBasePaths = combinationsOfBasePathVariableValues.map((mapOfVariablesToValues) => convertTemplateExpressionToConcreteExpression(basePath, mapOfVariablesToValues));
|
|
28
|
+
return possibleBasePaths;
|
|
29
|
+
};
|
|
30
|
+
const getPossibleBasePaths = (url, serverVariables) => {
|
|
31
|
+
const basePath = getBasePath(url);
|
|
32
|
+
return serverVariables
|
|
33
|
+
? getPossibleConcreteBasePaths(basePath, serverVariables)
|
|
34
|
+
: [basePath];
|
|
35
|
+
};
|
|
36
|
+
const getMatchingServerUrlsAndServerBasePaths = (servers, pathname) => {
|
|
37
|
+
const matchesPathname = (basePath) => pathname.startsWith(basePath);
|
|
38
|
+
return servers
|
|
39
|
+
.map(({ url: templatedUrl, variables }) => ({
|
|
40
|
+
templatedUrl,
|
|
41
|
+
possibleBasePaths: getPossibleBasePaths(templatedUrl, variables),
|
|
42
|
+
}))
|
|
43
|
+
.filter(({ possibleBasePaths }) => possibleBasePaths.some(matchesPathname))
|
|
44
|
+
.map(({ templatedUrl, possibleBasePaths }) => {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
46
|
+
const matchingBasePath = possibleBasePaths.find(matchesPathname);
|
|
47
|
+
return {
|
|
48
|
+
concreteUrl: templatedUrl.replace(getBasePath(templatedUrl), matchingBasePath),
|
|
49
|
+
matchingBasePath,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.getMatchingServerUrlsAndServerBasePaths = getMatchingServerUrlsAndServerBasePaths;
|
|
54
|
+
//# sourceMappingURL=OpenApi3Spec.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApi3Spec.utils.js","sourceRoot":"","sources":["../../lib/utils/OpenApi3Spec.utils.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA0C;AAE1C,iDAAiD;AAIjD,MAAM,MAAM,GAAG,CAAI,KAAU,EAAO,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,K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AAiB,EAAE,EAAE,EAAE;QAC3C,oEAAoE;QACpE,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAE,CAAC;QAClE,OAAO;YACL,WAAW,EAAE,YAAY,CAAC,OAAO,CAC/B,WAAW,CAAC,YAAY,CAAC,EACzB,gBAAgB,CACjB;YACD,gBAAgB;SACjB,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAvBW,QAAA,uCAAuC,2CAuBlD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ActualRequest } from '../classes/AbstractResponse';
|
|
2
|
+
export declare const stringify: (obj: unknown) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Excludes the query because path = pathname + query
|
|
5
|
+
*/
|
|
6
|
+
export declare const getPathname: (request: ActualRequest) => string;
|
|
7
|
+
export declare const findOpenApiPathMatchingPossiblePathnames: (possiblePathnames: string[], OAPaths: string[]) => string | undefined;
|
|
8
|
+
export declare const defaultBasePath = "/";
|
|
9
|
+
export declare const getPathnameWithoutBasePath: (basePath: string, pathname: string) => string;
|
|
10
|
+
//# sourceMappingURL=common.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.utils.d.ts","sourceRoot":"","sources":["../../lib/utils/common.utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,KAAG,MACV,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,aAAa,KAAG,MAElB,CAAC;AAiCpC,eAAO,MAAM,wCAAwC,GACnD,mBAAmB,MAAM,EAAE,EAC3B,SAAS,MAAM,EAAE,KAChB,MAAM,GAAG,SAeX,CAAC;AAEF,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,0BAA0B,GACrC,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,MACuE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPathnameWithoutBasePath = exports.defaultBasePath = exports.findOpenApiPathMatchingPossiblePathnames = exports.getPathname = exports.stringify = void 0;
|
|
7
|
+
const path_parser_1 = require("path-parser");
|
|
8
|
+
const url_1 = __importDefault(require("url"));
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const stringify = (obj) => (0, util_1.inspect)(obj, { depth: null });
|
|
11
|
+
exports.stringify = stringify;
|
|
12
|
+
/**
|
|
13
|
+
* Excludes the query because path = pathname + query
|
|
14
|
+
*/
|
|
15
|
+
const getPathname = (request) =>
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
|
+
url_1.default.parse(request.path).pathname;
|
|
18
|
+
exports.getPathname = getPathname;
|
|
19
|
+
/**
|
|
20
|
+
* Converts all {foo} to :foo
|
|
21
|
+
*/
|
|
22
|
+
const convertOpenApiPathToColonForm = (openApiPath) => openApiPath.replace(/{/g, ':').replace(/}/g, '');
|
|
23
|
+
const doesColonPathMatchPathname = (pathInColonForm, pathname) => {
|
|
24
|
+
/*
|
|
25
|
+
* By default, OpenAPI path parameters have `style: simple; explode: false` (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object)
|
|
26
|
+
* So array path parameters in the pathname of the actual request should be in the form: `/pathParams/a,b,c`
|
|
27
|
+
* `path-parser` fails to match parameter patterns to parameters containing commas.
|
|
28
|
+
* So we remove the commas.
|
|
29
|
+
*/
|
|
30
|
+
const pathWithoutCommas = pathname.replace(/,/g, '');
|
|
31
|
+
const pathParamsInPathname = new path_parser_1.Path(pathInColonForm).test(pathWithoutCommas); // => one of: null, {}, {exampleParam: 'foo'}
|
|
32
|
+
return Boolean(pathParamsInPathname);
|
|
33
|
+
};
|
|
34
|
+
const doesOpenApiPathMatchPathname = (openApiPath, pathname) => {
|
|
35
|
+
const pathInColonForm = convertOpenApiPathToColonForm(openApiPath);
|
|
36
|
+
return doesColonPathMatchPathname(pathInColonForm, pathname);
|
|
37
|
+
};
|
|
38
|
+
const findOpenApiPathMatchingPossiblePathnames = (possiblePathnames, OAPaths) => {
|
|
39
|
+
let openApiPath;
|
|
40
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
41
|
+
for (const pathname of possiblePathnames) {
|
|
42
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
43
|
+
for (const OAPath of OAPaths) {
|
|
44
|
+
if (OAPath === pathname) {
|
|
45
|
+
return OAPath;
|
|
46
|
+
}
|
|
47
|
+
if (doesOpenApiPathMatchPathname(OAPath, pathname)) {
|
|
48
|
+
openApiPath = OAPath;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return openApiPath;
|
|
53
|
+
};
|
|
54
|
+
exports.findOpenApiPathMatchingPossiblePathnames = findOpenApiPathMatchingPossiblePathnames;
|
|
55
|
+
exports.defaultBasePath = '/';
|
|
56
|
+
const getPathnameWithoutBasePath = (basePath, pathname) => basePath === exports.defaultBasePath ? pathname : pathname.replace(basePath, '');
|
|
57
|
+
exports.getPathnameWithoutBasePath = getPathnameWithoutBasePath;
|
|
58
|
+
//# sourceMappingURL=common.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.utils.js","sourceRoot":"","sources":["../../lib/utils/common.utils.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAmC;AACnC,8CAAsB;AACtB,+BAA+B;AAGxB,MAAM,SAAS,GAAG,CAAC,GAAY,EAAU,EAAE,CAChD,IAAA,cAAO,EAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AADnB,QAAA,SAAS,aACU;AAEhC;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BACnD,WAAW,GAAG,MAAM,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAlBW,QAAA,wCAAwC,4CAkBnD;AAEW,QAAA,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,0BAA0B,GAAG,CACxC,QAAgB,EAChB,QAAgB,EACR,EAAE,CACV,QAAQ,KAAK,uBAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAJ9D,QAAA,0BAA0B,8BAIoC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ehuelsmann/openapi-validator",
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "Common code for jest-openapi and Chai OpenAPI Response Validator",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rimraf dist",
|
|
9
|
+
"format": "prettier --write . --ignore-path ../../.prettierignore",
|
|
10
|
+
"lint": "tsc --noEmit && eslint .",
|
|
11
|
+
"lint:fix": "yarn lint --fix",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo",
|
|
14
|
+
"test:ci": "echo",
|
|
15
|
+
"prepack": "yarn build"
|
|
16
|
+
},
|
|
17
|
+
"repository": "https://github.com/openapi-library/OpenAPIValidators/tree/master/packages/openapi-validator",
|
|
18
|
+
"author": "OpenApiChai <openapichai@gmail.com>",
|
|
19
|
+
"contributors": [
|
|
20
|
+
"rwalle61 <richard.lh.waller@gmail.com>",
|
|
21
|
+
"Jonny Spruce <jspruce94@gmail.com>"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"jest",
|
|
26
|
+
"chai",
|
|
27
|
+
"openapi",
|
|
28
|
+
"testing",
|
|
29
|
+
"response",
|
|
30
|
+
"validate"
|
|
31
|
+
],
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/openapi-library/OpenAPIValidators/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/openapi-library/OpenAPIValidators#openapi-validators",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@types/request": "^2.48.7",
|
|
44
|
+
"@types/superagent": "^4.1.12",
|
|
45
|
+
"axios": "^1.15.0",
|
|
46
|
+
"combos": "^0.2.0",
|
|
47
|
+
"fs-extra": "^9.0.0",
|
|
48
|
+
"js-yaml": "^4.0.0",
|
|
49
|
+
"openapi-response-validator": "^12.1.3",
|
|
50
|
+
"openapi-schema-validator": "^9.2.0",
|
|
51
|
+
"path-parser": "^6.1.0",
|
|
52
|
+
"typeof": "^1.0.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/fs-extra": "^9.0.12",
|
|
56
|
+
"@types/js-yaml": "^4.0.3",
|
|
57
|
+
"@types/typeof": "^1.0.0",
|
|
58
|
+
"openapi-types": "^12.1.3"
|
|
59
|
+
}
|
|
60
|
+
}
|