mpx-api 1.0.0 → 1.0.2
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/package.json +11 -4
- package/src/lib/http-client.js +9 -1
- package/CONTRIBUTING.md +0 -71
- package/examples/github-api.yaml +0 -35
- package/examples/jsonplaceholder.yaml +0 -52
- package/examples/openapi-petstore.yaml +0 -88
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mpx-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Developer-first API testing, mocking, and documentation CLI",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"mpx-api": "
|
|
7
|
+
"mpx-api": "bin/mpx-api.js"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"api",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/mesaplexdev/mpx-api.git"
|
|
25
|
+
"url": "git+https://github.com/mesaplexdev/mpx-api.git"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
28
28
|
"url": "https://github.com/mesaplexdev/mpx-api/issues"
|
|
@@ -47,5 +47,12 @@
|
|
|
47
47
|
"tough-cookie": "^4.1.3",
|
|
48
48
|
"filenamify": "^6.0.0"
|
|
49
49
|
},
|
|
50
|
-
"devDependencies": {}
|
|
50
|
+
"devDependencies": {},
|
|
51
|
+
"files": [
|
|
52
|
+
"src/",
|
|
53
|
+
"bin/",
|
|
54
|
+
"README.md",
|
|
55
|
+
"LICENSE",
|
|
56
|
+
"package.json"
|
|
57
|
+
]
|
|
51
58
|
}
|
package/src/lib/http-client.js
CHANGED
|
@@ -38,9 +38,17 @@ export class HttpClient {
|
|
|
38
38
|
async request(method, url, options = {}) {
|
|
39
39
|
const startTime = Date.now();
|
|
40
40
|
|
|
41
|
+
// Set default User-Agent, allow override via options.headers
|
|
42
|
+
const defaultHeaders = {
|
|
43
|
+
'user-agent': 'mpx-api/1.0.1',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Merge headers, with user headers taking precedence
|
|
47
|
+
const headers = { ...defaultHeaders, ...(options.headers || {}) };
|
|
48
|
+
|
|
41
49
|
const requestOptions = {
|
|
42
50
|
method: method.toUpperCase(),
|
|
43
|
-
headers
|
|
51
|
+
headers,
|
|
44
52
|
body: options.body,
|
|
45
53
|
};
|
|
46
54
|
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Contributing to mpx-api
|
|
2
|
-
|
|
3
|
-
Thanks for your interest in contributing to mpx-api! We welcome contributions from the community.
|
|
4
|
-
|
|
5
|
-
## Development Setup
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Clone the repository
|
|
9
|
-
git clone https://github.com/mesaplex/mpx-api.git
|
|
10
|
-
cd mpx-api
|
|
11
|
-
|
|
12
|
-
# Install dependencies
|
|
13
|
-
npm install
|
|
14
|
-
|
|
15
|
-
# Link for local development
|
|
16
|
-
npm link
|
|
17
|
-
|
|
18
|
-
# Run tests
|
|
19
|
-
npm test
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Testing
|
|
23
|
-
|
|
24
|
-
All pull requests must include tests. We use Node.js built-in test runner.
|
|
25
|
-
|
|
26
|
-
Run tests:
|
|
27
|
-
```bash
|
|
28
|
-
npm test
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Add tests in the `test/` directory with the `.test.js` extension.
|
|
32
|
-
|
|
33
|
-
## Code Style
|
|
34
|
-
|
|
35
|
-
- Use ES modules (import/export)
|
|
36
|
-
- 2-space indentation
|
|
37
|
-
- Semicolons required
|
|
38
|
-
- Descriptive variable names
|
|
39
|
-
- Comment complex logic
|
|
40
|
-
|
|
41
|
-
## Pull Request Process
|
|
42
|
-
|
|
43
|
-
1. Fork the repository
|
|
44
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
45
|
-
3. Make your changes
|
|
46
|
-
4. Add tests for new functionality
|
|
47
|
-
5. Ensure all tests pass (`npm test`)
|
|
48
|
-
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
49
|
-
7. Push to your fork (`git push origin feature/amazing-feature`)
|
|
50
|
-
8. Open a Pull Request
|
|
51
|
-
|
|
52
|
-
## Feature Requests
|
|
53
|
-
|
|
54
|
-
Open an issue with the "enhancement" label. Please include:
|
|
55
|
-
- Use case / problem you're trying to solve
|
|
56
|
-
- Proposed solution
|
|
57
|
-
- Alternative solutions considered
|
|
58
|
-
|
|
59
|
-
## Bug Reports
|
|
60
|
-
|
|
61
|
-
Open an issue with the "bug" label. Please include:
|
|
62
|
-
- Steps to reproduce
|
|
63
|
-
- Expected behavior
|
|
64
|
-
- Actual behavior
|
|
65
|
-
- mpx-api version (`mpx-api --version`)
|
|
66
|
-
- Node.js version (`node --version`)
|
|
67
|
-
- Operating system
|
|
68
|
-
|
|
69
|
-
## License
|
|
70
|
-
|
|
71
|
-
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/examples/github-api.yaml
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
name: GitHub API Collection
|
|
2
|
-
description: Example collection for GitHub API with request chaining
|
|
3
|
-
baseUrl: https://api.github.com
|
|
4
|
-
|
|
5
|
-
requests:
|
|
6
|
-
- name: get-user
|
|
7
|
-
method: GET
|
|
8
|
-
url: /users/octocat
|
|
9
|
-
headers:
|
|
10
|
-
Accept: application/vnd.github+json
|
|
11
|
-
User-Agent: mpx-api
|
|
12
|
-
assert:
|
|
13
|
-
status: 200
|
|
14
|
-
body.login: octocat
|
|
15
|
-
body.type: User
|
|
16
|
-
|
|
17
|
-
- name: get-repos
|
|
18
|
-
method: GET
|
|
19
|
-
url: /users/{{get-user.response.body.login}}/repos
|
|
20
|
-
headers:
|
|
21
|
-
Accept: application/vnd.github+json
|
|
22
|
-
User-Agent: mpx-api
|
|
23
|
-
assert:
|
|
24
|
-
status: 200
|
|
25
|
-
body.length: { gt: 0 }
|
|
26
|
-
|
|
27
|
-
- name: get-first-repo
|
|
28
|
-
method: GET
|
|
29
|
-
url: "{{get-repos.response.body[0].url}}"
|
|
30
|
-
headers:
|
|
31
|
-
Accept: application/vnd.github+json
|
|
32
|
-
User-Agent: mpx-api
|
|
33
|
-
assert:
|
|
34
|
-
status: 200
|
|
35
|
-
body.owner.login: octocat
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
name: JSONPlaceholder API Tests
|
|
2
|
-
description: Example collection testing JSONPlaceholder API
|
|
3
|
-
baseUrl: https://jsonplaceholder.typicode.com
|
|
4
|
-
|
|
5
|
-
requests:
|
|
6
|
-
- name: Get all users
|
|
7
|
-
method: GET
|
|
8
|
-
url: /users
|
|
9
|
-
assert:
|
|
10
|
-
status: 200
|
|
11
|
-
body.length: { gt: 0 }
|
|
12
|
-
headers.content-type: application/json
|
|
13
|
-
responseTime: { lt: 2000 }
|
|
14
|
-
|
|
15
|
-
- name: Get specific user
|
|
16
|
-
method: GET
|
|
17
|
-
url: /users/1
|
|
18
|
-
assert:
|
|
19
|
-
status: 200
|
|
20
|
-
body.id: 1
|
|
21
|
-
body.name: { exists: true }
|
|
22
|
-
body.email: { exists: true }
|
|
23
|
-
|
|
24
|
-
- name: Create new post
|
|
25
|
-
method: POST
|
|
26
|
-
url: /posts
|
|
27
|
-
json:
|
|
28
|
-
title: Test Post
|
|
29
|
-
body: This is a test post created by mpx-api
|
|
30
|
-
userId: 1
|
|
31
|
-
assert:
|
|
32
|
-
status: 201
|
|
33
|
-
body.title: Test Post
|
|
34
|
-
body.userId: 1
|
|
35
|
-
|
|
36
|
-
- name: Update post
|
|
37
|
-
method: PUT
|
|
38
|
-
url: /posts/1
|
|
39
|
-
json:
|
|
40
|
-
id: 1
|
|
41
|
-
title: Updated Title
|
|
42
|
-
body: Updated content
|
|
43
|
-
userId: 1
|
|
44
|
-
assert:
|
|
45
|
-
status: 200
|
|
46
|
-
body.title: Updated Title
|
|
47
|
-
|
|
48
|
-
- name: Delete post
|
|
49
|
-
method: DELETE
|
|
50
|
-
url: /posts/1
|
|
51
|
-
assert:
|
|
52
|
-
status: 200
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
openapi: 3.0.0
|
|
2
|
-
info:
|
|
3
|
-
title: Pet Store API
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
description: A simple pet store API for testing mpx-api mock server
|
|
6
|
-
|
|
7
|
-
paths:
|
|
8
|
-
/pets:
|
|
9
|
-
get:
|
|
10
|
-
summary: List all pets
|
|
11
|
-
responses:
|
|
12
|
-
'200':
|
|
13
|
-
description: A list of pets
|
|
14
|
-
content:
|
|
15
|
-
application/json:
|
|
16
|
-
schema:
|
|
17
|
-
type: array
|
|
18
|
-
items:
|
|
19
|
-
type: object
|
|
20
|
-
properties:
|
|
21
|
-
id:
|
|
22
|
-
type: integer
|
|
23
|
-
example: 1
|
|
24
|
-
name:
|
|
25
|
-
type: string
|
|
26
|
-
example: "Fluffy"
|
|
27
|
-
species:
|
|
28
|
-
type: string
|
|
29
|
-
example: "cat"
|
|
30
|
-
|
|
31
|
-
post:
|
|
32
|
-
summary: Create a pet
|
|
33
|
-
requestBody:
|
|
34
|
-
content:
|
|
35
|
-
application/json:
|
|
36
|
-
schema:
|
|
37
|
-
type: object
|
|
38
|
-
properties:
|
|
39
|
-
name:
|
|
40
|
-
type: string
|
|
41
|
-
species:
|
|
42
|
-
type: string
|
|
43
|
-
responses:
|
|
44
|
-
'201':
|
|
45
|
-
description: Pet created
|
|
46
|
-
content:
|
|
47
|
-
application/json:
|
|
48
|
-
schema:
|
|
49
|
-
type: object
|
|
50
|
-
properties:
|
|
51
|
-
id:
|
|
52
|
-
type: integer
|
|
53
|
-
example: 2
|
|
54
|
-
name:
|
|
55
|
-
type: string
|
|
56
|
-
example: "Buddy"
|
|
57
|
-
species:
|
|
58
|
-
type: string
|
|
59
|
-
example: "dog"
|
|
60
|
-
|
|
61
|
-
/pets/{id}:
|
|
62
|
-
get:
|
|
63
|
-
summary: Get a pet by ID
|
|
64
|
-
parameters:
|
|
65
|
-
- name: id
|
|
66
|
-
in: path
|
|
67
|
-
required: true
|
|
68
|
-
schema:
|
|
69
|
-
type: integer
|
|
70
|
-
responses:
|
|
71
|
-
'200':
|
|
72
|
-
description: A single pet
|
|
73
|
-
content:
|
|
74
|
-
application/json:
|
|
75
|
-
schema:
|
|
76
|
-
type: object
|
|
77
|
-
properties:
|
|
78
|
-
id:
|
|
79
|
-
type: integer
|
|
80
|
-
example: 1
|
|
81
|
-
name:
|
|
82
|
-
type: string
|
|
83
|
-
example: "Fluffy"
|
|
84
|
-
species:
|
|
85
|
-
type: string
|
|
86
|
-
example: "cat"
|
|
87
|
-
'404':
|
|
88
|
-
description: Pet not found
|