com.moclojer/moclojer
Simple and efficient HTTP and Webscoket mock server with specification in yaml, edn or OpenAPI
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.6%) to scientific vocabulary
Keywords
Repository
Simple and efficient HTTP and Webscoket mock server with specification in yaml, edn or OpenAPI
Basic Info
- Host: GitHub
- Owner: moclojer
- License: mit
- Language: Clojure
- Default Branch: main
- Homepage: https://docs.moclojer.com
- Size: 749 KB
Statistics
- Stars: 125
- Watchers: 3
- Forks: 13
- Open Issues: 15
- Releases: 10
Topics
Metadata Files
README.md
Simple and efficient HTTP mock server with specification written in yaml, edn or OpenAPI.
💾 Download the
.jarfile with the latest version of moclojer to test on your computer here.
📖 See the complete documentation for moclojer here, if you want to contribute (or complement) the documentation, it is here.
YAML example
```yaml
This mock register route: GET /hello/:username
- endpoint: # Note: the method could be omitted because GET is the default method: GET path: /hello/:username response: # Note: the status could be omitted because 200 is the default status: 200 headers: Content-Type: application/json # Note: the body will receive the value passed in the url using the # :username placeholder body: > { "hello": "{{path-params.username}}!" } ```
WebSocket Support
Moclojer also supports WebSocket connections with a simple configuration approach:
```yaml
WebSocket echo server
- websocket:
path: /ws/echo
on-connect:
# Message sent when client connects
response: '{"status": "connected", "message": "Welcome to WebSocket Echo!"}'
on-message:
# Simple echo for "ping" message
- pattern: "ping" response: "pong" # Echo back any JSON content with an "echo" field
- pattern: '{"echo": "{{json-params.echo}}"}' response: '{"echoed": "{{json-params.echo}}"}' ```
You can test the WebSocket connection using tools like websocat:
sh
websocat "ws://localhost:8000/ws/echo" --text
docker
- image:
ghcr.io/moclojer/moclojer:latest - port (default):
8000, if you want to change the port set the environment variablePORT
sh
docker run -it \
-p 8000:8000 -v $(pwd)/moclojer.yml:/app/moclojer.yml \
ghcr.io/moclojer/moclojer:latest
We have two versions available:
dev: main branch docker imagelatest: latest stable version image
manual installation
We distribute via the .jar file, you need to have Java installed on your operating system.
sh
bash < <(curl -s https://raw.githubusercontent.com/moclojer/moclojer/main/install.sh)
If you are using Linux you maybe need
sudo.
CLI Usage
clj -M:run [OPTIONS]java -jar moclojer.jar [OPTIONS]moclojer_Linux [OPTIONS]
Options
parameter | description
--- | ---
-c, --config | Config path or the CONFIG environment variable. [default: ~/.config/moclojer.yml]
-m, --mocks | OpenAPI v3 mocks path or the MOCKS environment variable.
-f, --format | Output and logging format. Either println or json.
-h, --help | Show help information
-v, --version | Show version information
sentry: set environment var SENTRY_DSN (sentry doc), automatic send backtrace to
Config uses
XDG_CONFIG_HOMEto fetch the default moclojer configuration file, if you want to set a different directory you must use the-cor environment variableCONFIG
💻 dev environment
moclojer is written in Clojure, to run the commands below we assume you have clojure installed on your operating system.
run:
sh
clj -M:run
test:
sh
clj -M:test
if you want to run a specific test:
clj -M:test -n com.moclojer.external-body.excel-test
moclojer.jar generate:
sh
clj -A:dev -M --report stderr -m com.moclojer.build
framework integrations
We distribute the library via Clojars.
Clojure CLI/deps.edn
clojure
com.moclojer/moclojer {:mvn/version "0.3.1"}
Leiningen/Boot
clojure
[com.moclojer/moclojer "0.3.1"]
git in deps.edn
edn
{:deps
{com.moclojer/moclojer {:git/url "https://github.com/moclojer/moclojer.git"
:git/tag "v0.3.1"
:git/sha "c4ca0f2cfcfbe47de6eb0c601b26106190e20793"}}}
example of use
```clj (ns my-app.core (:require [com.moclojer.adapters :as adapters] [com.moclojer.server :as server]))
(def *router "create a router from a config map" (adapters/generate-routes [{:endpoint {:method "GET" :path "/example" :response {:status 200 :headers {:Content-Type "application/json"} :body {:id 123}}}}]))
(defn -main "start the server" & args) ```
Owner
- Name: moclojer
- Login: moclojer
- Kind: organization
- Email: hey@moclojer.com
- Website: https://moclojer.com
- Repositories: 3
- Profile: https://github.com/moclojer
Simple and efficient HTTP mock server with specification in yaml, edn or OpenAPI
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Avelino" given-names: "Thiago" orcid: "https://orcid.org/0009-0009-0466-4844" title: "moclojer" url: "https://github.com/moclojer/moclojer"
GitHub Events
Total
- Create event: 31
- Release event: 2
- Issues event: 22
- Watch event: 14
- Delete event: 25
- Issue comment event: 37
- Push event: 81
- Pull request review comment event: 134
- Pull request review event: 104
- Pull request event: 40
- Fork event: 1
Last Year
- Create event: 31
- Release event: 2
- Issues event: 22
- Watch event: 14
- Delete event: 25
- Issue comment event: 37
- Push event: 81
- Pull request review comment event: 134
- Pull request review event: 104
- Pull request event: 40
- Fork event: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 15
- Total pull requests: 15
- Average time to close issues: 7 months
- Average time to close pull requests: 2 days
- Total issue authors: 4
- Total pull request authors: 3
- Average comments per issue: 0.07
- Average comments per pull request: 1.2
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 9
Past Year
- Issues: 12
- Pull requests: 15
- Average time to close issues: 29 days
- Average time to close pull requests: 2 days
- Issue authors: 4
- Pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 1.2
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 9
Top Authors
Issue Authors
- avelino (23)
- matheusfrancisco (4)
- J0sueTM (4)
- vmesel (2)
- Felipe-gsilva (1)
- skkflkfd123 (1)
Pull Request Authors
- dependabot[bot] (38)
- avelino (20)
- J0sueTM (8)
- matheusfrancisco (2)
- joaomedeiros95 (1)
- grigolin (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- clojars 460 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 7
- Total maintainers: 1
clojars.org: com.moclojer/moclojer
Simple and efficient HTTP mock server with specification written in `yaml`, `edn` or `OpenAPI`.
- Homepage: https://moclojer.com
- Documentation: https://cljdoc.org/d/com.moclojer/moclojer/
- License: MIT License
-
Latest release: 0.4.0
published 11 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- clj-holmes/clj-holmes-action 200d2d03900917d7eb3c24fc691ab83579a87fcb composite
- github/codeql-action/upload-sarif v2 composite
- actions/checkout v3 composite
- docker/login-action v2 composite
- DeLaGuardo/setup-clj-kondo master composite
- actions/checkout v3 composite
- DeLaGuardo/setup-clojure 10.1 composite
- actions/checkout v3 composite
- docker.io/clojure openjdk-19-tools-deps-bullseye build
- docker.io/clojure openjdk-19-tools-deps-slim-bullseye build
- docker.io/openjdk 19-jdk-alpine build
- DeLaGuardo/setup-clojure 12.1 composite
- actions/cache v3.3.2 composite
- actions/checkout v4 composite
- softprops/action-gh-release master composite
- DeLaGuardo/setup-clojure 12.1 composite
- actions/checkout v4 composite
- actions/upload-artifact v3.1.3 composite
- graalvm/setup-graalvm v1 composite
- DavidAnson/markdownlint-cli2-action v14 composite
- actions/checkout v4 composite