japa-openapi-assertions 0.1.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.
@@ -0,0 +1,126 @@
1
+ import type { ValidateFunction } from 'ajv';
2
+ /**
3
+ * Plugin configuration options
4
+ */
5
+ export interface PluginConfig {
6
+ /**
7
+ * Paths to OpenAPI specification files (JSON or YAML)
8
+ */
9
+ schemas: (string | URL)[];
10
+ /**
11
+ * Print coverage report to console on process exit
12
+ */
13
+ reportCoverage?: boolean;
14
+ /**
15
+ * Export coverage data to coverage.json on process exit
16
+ */
17
+ exportCoverage?: boolean;
18
+ }
19
+ /**
20
+ * Compiled validators for a single response
21
+ */
22
+ export interface ResponseValidators {
23
+ body?: ValidateFunction;
24
+ headers?: ValidateFunction;
25
+ }
26
+ /**
27
+ * Compiled validators organized by path, method, and status code
28
+ */
29
+ export interface CompiledValidators {
30
+ [path: string]: {
31
+ [method: string]: {
32
+ responses: {
33
+ [statusCode: string]: ResponseValidators;
34
+ };
35
+ };
36
+ };
37
+ }
38
+ /**
39
+ * Parsed response data from various HTTP client formats
40
+ */
41
+ export interface ParsedResponse {
42
+ method: string;
43
+ path: string;
44
+ status: number;
45
+ headers: Record<string, string>;
46
+ body: unknown;
47
+ }
48
+ /**
49
+ * Validation error details
50
+ */
51
+ export interface ValidationError {
52
+ path: string;
53
+ message: string;
54
+ keyword?: string;
55
+ expected?: unknown;
56
+ actual?: unknown;
57
+ }
58
+ /**
59
+ * Result of validating a response
60
+ */
61
+ export interface ValidationResult {
62
+ valid: boolean;
63
+ errors?: ValidationError[];
64
+ }
65
+ /**
66
+ * Path matching result
67
+ */
68
+ export interface PathMatchResult {
69
+ matched: string;
70
+ params: Record<string, string>;
71
+ }
72
+ /**
73
+ * Coverage entry for a single endpoint
74
+ */
75
+ export interface CoverageEntry {
76
+ route: string;
77
+ method: string;
78
+ statuses: string[];
79
+ }
80
+ /**
81
+ * OpenAPI document types (simplified)
82
+ */
83
+ export interface OpenAPIDocument {
84
+ openapi: string;
85
+ info: {
86
+ title: string;
87
+ version: string;
88
+ };
89
+ paths?: {
90
+ [path: string]: OpenAPIPathItem;
91
+ };
92
+ components?: {
93
+ schemas?: Record<string, unknown>;
94
+ };
95
+ }
96
+ export interface OpenAPIPathItem {
97
+ get?: OpenAPIOperation;
98
+ post?: OpenAPIOperation;
99
+ put?: OpenAPIOperation;
100
+ patch?: OpenAPIOperation;
101
+ delete?: OpenAPIOperation;
102
+ options?: OpenAPIOperation;
103
+ head?: OpenAPIOperation;
104
+ trace?: OpenAPIOperation;
105
+ parameters?: unknown[];
106
+ }
107
+ export interface OpenAPIOperation {
108
+ operationId?: string;
109
+ summary?: string;
110
+ description?: string;
111
+ responses?: {
112
+ [statusCode: string]: OpenAPIResponse;
113
+ };
114
+ requestBody?: unknown;
115
+ parameters?: unknown[];
116
+ }
117
+ export interface OpenAPIResponse {
118
+ description?: string;
119
+ content?: {
120
+ [mediaType: string]: {
121
+ schema?: unknown;
122
+ };
123
+ };
124
+ headers?: Record<string, unknown>;
125
+ }
126
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAE3C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAA;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,CAAC,IAAI,EAAE,MAAM,G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,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAClC,CAAA;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE;QACV,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAAA;KACtC,CAAA;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE;QACR,CAAC,SAAS,EAAE,MAAM,GAAG;YACnB,MAAM,CAAC,EAAE,OAAO,CAAA;SACjB,CAAA;KACF,CAAA;IACD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC"}
package/build/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "japa-openapi-assertions",
3
+ "version": "0.1.0",
4
+ "description": "OpenAPI 3.1 Assertions plugin for Japa (fork of @japa/openapi-assertions)",
5
+ "type": "module",
6
+ "main": "build/index.js",
7
+ "types": "build/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./build/index.js",
11
+ "types": "./build/index.d.ts"
12
+ }
13
+ },
14
+ "engines": {
15
+ "node": ">=20.6.0"
16
+ },
17
+ "files": [
18
+ "build",
19
+ "!build/tests"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "typecheck": "tsc --noEmit",
24
+ "lint": "eslint src",
25
+ "test": "node --import tsx --test tests/**/*.spec.ts"
26
+ },
27
+ "dependencies": {
28
+ "ajv": "^8.17.1",
29
+ "ajv-formats": "^3.0.1",
30
+ "@seriousme/openapi-schema-validator": "^2.7.0",
31
+ "chalk": "^5.4.1"
32
+ },
33
+ "peerDependencies": {
34
+ "@japa/assert": "^4.0.0",
35
+ "@japa/runner": "^3.0.0 || ^4.0.0 || ^5.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.15.18",
39
+ "tsx": "^4.19.0",
40
+ "typescript": "~5.8"
41
+ },
42
+ "keywords": [
43
+ "openapi",
44
+ "openapi-3.1",
45
+ "japa",
46
+ "assert",
47
+ "api-testing",
48
+ "json-schema"
49
+ ],
50
+ "author": "Drew Daniels",
51
+ "license": "MIT",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "https://github.com/drew-daniels/japa-openapi-assertions"
55
+ },
56
+ "homepage": "https://github.com/drew-daniels/japa-openapi-assertions#readme",
57
+ "bugs": {
58
+ "url": "https://github.com/drew-daniels/japa-openapi-assertions/issues"
59
+ }
60
+ }