-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ee1e0b
commit 4e90d0c
Showing
29 changed files
with
2,681 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
# camoswag | ||
# Camoswag | ||
|
||
Camoswag is a Camouflage extension which allows you to generate your mockfiles using an OpenAPI Specification. | ||
|
||
For more information on Camouflage, see [documentation](https://fauxauldrich.github.io/camouflage/) | ||
|
||
# Getting Started | ||
|
||
- To use `camoswag`, you would need your OpenAPI specification file in either .json or .yaml format. | ||
- You don't need to install `camoswag` in order to run, you can simply run it using `npx` | ||
- Run the command: `npx camoswag --spec ./swagger.yaml` or `npx camoswag --spec ./swagger.json`. (Replace file location with your spec file location) | ||
- This would create a new folder with the name `camouflage-${current_timestamp}` containing the required folder structure and mock files corresponding to each endpoint defined in your spec file. | ||
- You can either delete or modify the dummy responses placed in the mockfiles as per your expectations. Once you are satisfied with the modifications, you can move the contents of the folder to your original ${MOCK_DIR} of your running Camouflage server. | ||
- Note that if your spec file doesn't contain a response defined for a given endpoint, `camoswag` would put following default response in the mock file. | ||
|
||
```json | ||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
``` | ||
|
||
Note: camoswag currenty supports JSON responses only. | ||
|
||
|
||
- To install `camoswag` locally, run command `npm i -g camoswag` | ||
- Run conversion command using `camoswag --spec ./swagger.yaml` or `camoswag --spec ./swagger.json`. (Replace file location with your spec file location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env node | ||
const argv = require("yargs").argv; | ||
const specFile = argv.s || argv.spec; | ||
const winston = require("winston"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const createMocks = require("../index"); | ||
|
||
const logger = winston.createLogger({ | ||
level: "info", | ||
format: winston.format.combine( | ||
winston.format.colorize(), | ||
winston.format.simple(), | ||
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), | ||
winston.format.printf((log) => `${log.timestamp} ${log.level}: ${log.message}` + (log.splat !== undefined ? `${log.splat}` : " ")) | ||
), | ||
transports: [new winston.transports.Console()], | ||
}); | ||
|
||
if (!specFile) { | ||
logger.error("Please specify at least one of the input parameters."); | ||
logger.info("Available options are: -s/--spec"); | ||
process.exit(1); | ||
} | ||
if (specFile) { | ||
const specFilePath = path.resolve(specFile); | ||
if (typeof specFile !== "string" || !fs.existsSync(specFilePath)) { | ||
logger.error(`${specFile} is not a valid file. Please provide a valid OpenAPI Specification file to proceed.`); | ||
process.exit(1); | ||
} else { | ||
createMocks(specFilePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 405 Method Not Allowed | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 405 Method Not Allowed | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"id": 3639836862840832, | ||
"category": { | ||
"id": -6904188336340992, | ||
"name": "msL" | ||
}, | ||
"name": "fWDXeudI", | ||
"photoUrls": [ | ||
"ZvvFZM" | ||
], | ||
"tags": [ | ||
{ | ||
"id": -5443327017091072, | ||
"name": "Ynsqh" | ||
} | ||
], | ||
"status": "pending" | ||
} | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 405 Method Not Allowed | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"code": 5688478750736384, | ||
"type": "L", | ||
"message": "Hr" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
[ | ||
{ | ||
"id": -6258476816793600, | ||
"category": { | ||
"id": -3109826385149952, | ||
"name": "mMRMXoHJnLD" | ||
}, | ||
"name": "PWejWKffNW", | ||
"photoUrls": [ | ||
"GvG" | ||
], | ||
"tags": [ | ||
{ | ||
"id": -5412031372984320, | ||
"name": "Aj" | ||
} | ||
], | ||
"status": "pending" | ||
} | ||
] | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
[ | ||
{ | ||
"id": 2527916277628928, | ||
"category": { | ||
"id": -6686392331534336, | ||
"name": "pd" | ||
}, | ||
"name": "nAxaUOtwWFJ", | ||
"photoUrls": [ | ||
"qrpe" | ||
], | ||
"tags": [ | ||
{ | ||
"id": -4633484505120768, | ||
"name": "yFswVK" | ||
} | ||
], | ||
"status": "sold" | ||
} | ||
] | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"kocakos": 830884307533824 | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"id": 5770442103062528, | ||
"petId": -1120756788363264, | ||
"quantity": -2879783742472192, | ||
"shipDate": "2021-05-17T16:33:19.023Z", | ||
"status": "placed", | ||
"complete": false | ||
} | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"id": -1220053982773248, | ||
"petId": -6279841993195520, | ||
"quantity": 6676552519516160, | ||
"shipDate": "2021-05-17T16:33:19.024Z", | ||
"status": "approved", | ||
"complete": false | ||
} | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 default undefined | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"id": 8407667567493120, | ||
"username": "yTOe", | ||
"firstName": "vLR", | ||
"lastName": "oiOmvG", | ||
"email": "AfLU", | ||
"password": "Hct", | ||
"phone": "ZUmmf", | ||
"userStatus": 7517871211020288 | ||
} | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== | ||
HTTP/1.1 404 Not Found | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 default undefined | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 default undefined | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
"ghsVE" | ||
==== | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"message": "More Configuration Needed" | ||
} | ||
==== |
Oops, something went wrong.