Kong / Kong/httpsnippet

Error: strict mode: unknown keyword: "afterRequest"

Đang mở
#335 3 bình luận 7 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
1.2k
Fork
242
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I am getting the below error when executing the basic example provided in the docs in my NodeJs project:

```
/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/index.js:120
throw e;
^

Error: strict mode: unknown keyword: "afterRequest"
at checkStrictMode (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/util.js:174:15)
at checkUnknownRules (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/util.js:32:13)
at checkKeywords (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/validate/index.js:120:34)
at validateFunctionCode (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/validate/index.js:19:9)
at Ajv.compileSchema (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/index.js:80:45)
at Ajv.resolveSchema (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/index.js:193:23)
at Ajv.getSchema (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/core.js:279:43)
at validateHarRequest (/Users/harsh/Desktop/http-snippet-demo/node_modules/httpsnippet/dist/helpers/har-validator.js:66:24)
at /Users/harsh/Desktop/http-snippet-demo/node_modules/httpsnippet/dist/httpsnippet.js:262:56
at Array.forEach ()
```

Example Code:
```
const express = require('express');
const { HTTPSnippet } = require('httpsnippet');

const app = express();

const snippet = new HTTPSnippet({
method: 'GET',
url: 'http://mockbin.com/request',
});

const options = { indent: '\t' };
const output = snippet.convert('shell', 'curl', options);
console.log(output);

const server = app.listen(8000, '0.0.0.0', () => {
console.log('Example app listening at http://%s:%s', server.address().address, server.address().port);
});
```
httpsnippet version in package.json file: **^3.0.1**
NodeJs version: **18.17**

I am getting the same error via CLI as well when executing the below command:
`httpsnippet example.json --target shell --client curl --output ./examples`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Reproduce the failure with the documented basic example and the `httpsnippet example.json --target shell --client curl --output ./examples` command, using the versions reported in the issue. Inspect the package.json dependency setup and the CLI entry point, then trace the validation path shown in the stack trace. Done means both documented invocation paths no longer fail on the unknown `afterRequest` keyword.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
node.js, typescript
Lĩnh vực
cli, tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.