{"id":14384742,"url":"https://github.com/leboncoin/morphlingjs","last_synced_at":"2025-04-04T20:03:13.997Z","repository":{"id":38917224,"uuid":"108252938","full_name":"leboncoin/morphlingjs","owner":"leboncoin","description":"A CLI to mock with meaningful data a REST API from a Swagger file","archived":false,"fork":false,"pushed_at":"2025-01-19T00:18:08.000Z","size":394,"stargazers_count":149,"open_issues_count":14,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-28T19:08:12.322Z","etag":null,"topics":["cli","docker","faker","leboncoin","mock","nodejs","swagger"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leboncoin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-25T10:07:53.000Z","updated_at":"2023-11-26T22:43:33.000Z","dependencies_parsed_at":"2025-03-02T18:08:22.617Z","dependency_job_id":"1573c924-b92e-48e5-b1ba-7be5daa27865","html_url":"https://github.com/leboncoin/morphlingjs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leboncoin%2Fmorphlingjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leboncoin%2Fmorphlingjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leboncoin%2Fmorphlingjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leboncoin%2Fmorphlingjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leboncoin","download_url":"https://codeload.github.com/leboncoin/morphlingjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242658,"owners_count":20907131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","docker","faker","leboncoin","mock","nodejs","swagger"],"created_at":"2024-08-28T18:01:37.884Z","updated_at":"2025-04-04T20:03:13.964Z","avatar_url":"https://github.com/leboncoin.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Morphling\n\n*Cause nobody aint got time to wait for back-ends to be developped.*\n\n\n## Features\n\n- A sweet all-in-CLI with **no knowledge of Javascript necessary** _(if you can write JSON you good 👍 )_\n- **Mocks any object, array or field** declared in a swagger with meaningful **autogenerated data**\n- **Persists route mocks** to allow you to develop your front-end as fast as a lightning\n- Uses **Faker generators** behind the curtains\n- **Empty responses, error codes, any http method, any body** _not sure about that last one but I'm trying ok_\n- Two lines install and **minimal knowledge of backend necessary**\n- Supports **JSON and YAML** swaggers\n- Supports (a big part of) **OpenAPI 3.0**\n\n## Installation\n\n- Ensure that you have both `docker` and `docker-compose` installed and available to your terminal.\n\n- Also, make sure that the docker daemon is running.\n\n- Now just go for it: `npm i -g morphlingjs` it takes a while so grab a cub of coffee on the way.\n\n- Run the configuration utility to select the port morphling will run on: `morphling config`\n\n- Add a swagger.yml file to Morphling by doing a `morphling apply your/file`\n\nNow morphling knows your swagger and can mock it properly. \nJust try to hit a route that is described in your swagger !\n\nTo see what swaggers Morphling knows do a `morphling list`.\n\n*Note: If having any issues during the install with npm such as 'Cannot read property 0 of undefined', \ntry to downgrade your current npm install to 5.2.0* \n\n## Overriding a route\n\nMorphling allows you to create a mock for a specific route ; because sometimes you need a specific body from your server.\n\nFor instance, you want your local server to return a specific response on a given route. It can be a route that is described\nin your swagger where you don't want autogenerated data or just a route you don't want to bother putting in the swagger.\n\nYou will want to use **an override file**, which you can find two examples of in the [examples](https://github.com/leboncoin/morphlingjs/tree/master/swagger-override-examples).\n\nDoing a \n\n- `morphling apply swagger-override-examples/demo.json -o` \n\nand then \n\n- `morphling toggle demo.json`\n\nwill create a route on `localhost:8883/v2/store/order/1` and then enable it (if morphling runs on 8883). This route will return, as seen in the example file,\na 200 (OK) HTTP code, with an empty body.\n\n## CLI Commands\n\nAny command here can be run with the `--help` flag to give you a tad more info 👍\n\n### help\n   - `help [cmd]             display help for [cmd]`\n\nDisplays the help\n\n### apply\n`apply|a \u003cfile\u003e         Apply a Swagger to morphling`\n\nSend a Swagger file to the Morphling instance for it to be mocked. \n\nIf used with `-o` flag, save file as an **Override file** to Morphling.\nOverrides are **disabled by default**. To enable/disable them, check the `toggle` command.\n\nThere is no validation working on the server at the time of writing this which means that it will break silently.\nIf a route is not mocked, I suggest that you `morphling bash` into the instance and run `pm2 logs` while trying to `apply` the swagger.\nMight give you some info. If not, please send an issue! I'll do my best to fix it ASAP.\n\n### bash\n   - `bash|b                 Bash into the morphling container`\n\nOpen a bash straight into the container. Useful for checking logs with `pm2 logs` for instance.\n\n### config\n   - `config|c               Configure the morphling server`\n   \nPersist CLI options, for instance the port that the CLI will hit on localhost\n\n### describe\n   - `describe|d \u003cfilename\u003e  Describe a morphling override`\n   \nDescribe an override file's content.\n\n### list\n   - `list|ls                List files saved in morphling`\n\nList all swaggers saved to Morphling. Use with `-o` to list override files.\n   \n### remove - NOT IMPLEMENTED YET\n\n   - `remove|rm              Remove a Swagger file saved in Morphling`\n### remove-all - NOT IMPLEMENTED YET\n\n   - `remove-all|rma         Clear Swagger files saved in Morphling`\n   \n### restart\n   - `restart|rr             Restart the morphling server`\n   \nRestart the Morphling instance. _who would have thought_\n\n### start\n   - `start|s                Start the morphling server on 8883 if no port is provided`\n   \nStart the morphling instance.\n\n### stop\n   - `stop|k                 Stop the morphling server`\\\n  \nStop the morphling instance.\n\n### toggle\n   - `toggle|t \u003cfilename\u003e    Toggle an override`\n   \nEnable/disable an override. Use with `-d` to disable all, or `-e` to enable all.\n\n\n_Note: if you think about other useful commands, feel free to submit an issue! 😉_\n\n## Installation from source \n\n_Here be dragons, you probably don't need to do this, except if want to contribute, which would be lovely._\n\nEnsure that you have both `docker` and `docker-compose` installed and available to your terminal.\n\n- Clone the package\n- Inside the package: `make start` and wait for the build to be over\n- If the message `Morphling started on 8883` pops, it means that everything went well!\n- `npm link` to make `morphling` available globally to your terminal\n- `morphling config` and go through the short process\n- `morphling --help` for other informations should help you out.\n\n*Note: If having any issues during the install with npm such as 'Cannot read property 0 of undefined', \ntry to downgrade your current npm install to 5.2.0* \n\n## Useful development commands\n\nI've made available a `morphling bash` command which immediately bashes you inside the currently-running Docker \ninstance of Morphling\n\n`make `\n\n- `start` Run the build proces and start the Morphling docker instance immediatly then pipe the logs\n- `dev` Start the server without docker on a bare Nodejs process\n- `build` Build all javascript files with *Babel*.\n- `docker-build` Run the docker build process and run the server.\n- `clear-docker` Hard-delete the Morphling instance from your local Docker\n- `devstart-hard` Clear all dependencies and docker Morphling instances and start\n\n## Upcoming features _feel free to submit PRs_\n\n- SwaggerUI!\n- Print proper Morphlingjs version with `--version / -v`\n- On the go switching of running ports\n- Add ID to overrides and Swagger files so you dont have to type them down / or maybe just autocomplete them\n- `morphling validate` A proper validator for the swagger files and an associated CLI command\n- `morphling remove` Remove a file from Morphling\n- `morphling remove-all` Remove all files from Morphling (also remove local saves of fixtures) always with --force\n- A better autocompletion using the npm package `commander-completion`\n- Overriding a field key in an object with a specific faker generator (ie: zipcode, username...)\n- Override checker (ensure that a specific override does not already exist when adding another one)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleboncoin%2Fmorphlingjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleboncoin%2Fmorphlingjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleboncoin%2Fmorphlingjs/lists"}