com.moclojer/moclojer

Simple and efficient HTTP and Webscoket mock server with specification in yaml, edn or OpenAPI

https://github.com/moclojer/moclojer

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

api api-mock api-mocker api-rest clojure edn hacktoberfest mock mock-server openapi openapi3 swagger swagger-api swagger2 yaml
Last synced: 6 months ago · JSON representation ·

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
api api-mock api-mocker api-rest clojure edn hacktoberfest mock mock-server openapi openapi3 swagger swagger-api swagger2 yaml
Created almost 4 years ago · Last pushed 9 months ago
Metadata Files
Readme Funding License Code of conduct Citation

README.md

moclojer

linter tests

moclojer -  Simple and efficient HTTP mock server with easy spec | Product Hunt

Simple and efficient HTTP mock server with specification written in yaml, edn or OpenAPI.

💾 Download the .jar file 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 variable PORT

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 image
  • latest: 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_HOME to fetch the default moclojer configuration file, if you want to set a different directory you must use the -c or environment variable CONFIG

💻 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

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
:enhancement (13) :feature (12) :devx (10) :bug (10) :app :cli (7) :spec :moclojer (5) :env :docker (4) :doc (3) :triage :pending (3) :webhook (3) :framework (2) :github :actions (2) :env :graalvm (2) :ci :cd (1) :duplicate (1) :good-first-issue (1) :file-type :json (1) :spec :openapi (1) :file-type :edn (1) :file-type :yaml (1) :log (1) :help :wanted (1) :dep (1)
Pull Request Labels
:github :actions (37) :dep (37) :bug (2) :app :cli (1) :enhancement (1) :devx (1) :spec :moclojer (1) :webhook (1)

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`.

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 460 Total
Rankings
Dependent packages count: 8.0%
Dependent repos count: 29.2%
Average: 45.6%
Downloads: 99.7%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/clj-holmes.yml actions
  • actions/checkout v3 composite
  • clj-holmes/clj-holmes-action 200d2d03900917d7eb3c24fc691ab83579a87fcb composite
  • github/codeql-action/upload-sarif v2 composite
.github/workflows/docker.yml actions
  • actions/checkout v3 composite
  • docker/login-action v2 composite
.github/workflows/linter.yml actions
  • DeLaGuardo/setup-clj-kondo master composite
  • actions/checkout v3 composite
.github/workflows/tests.yml actions
  • DeLaGuardo/setup-clojure 10.1 composite
  • actions/checkout v3 composite
.devcontainer/Dockerfile docker
  • docker.io/clojure openjdk-19-tools-deps-bullseye build
Dockerfile docker
  • docker.io/clojure openjdk-19-tools-deps-slim-bullseye build
  • docker.io/openjdk 19-jdk-alpine build
.github/workflows/build-jar.yml actions
  • DeLaGuardo/setup-clojure 12.1 composite
  • actions/cache v3.3.2 composite
  • actions/checkout v4 composite
  • softprops/action-gh-release master composite
.github/workflows/build-native-image.yml actions
  • DeLaGuardo/setup-clojure 12.1 composite
  • actions/checkout v4 composite
  • actions/upload-artifact v3.1.3 composite
  • graalvm/setup-graalvm v1 composite
.github/workflows/md-checker.yaml actions
  • DavidAnson/markdownlint-cli2-action v14 composite
  • actions/checkout v4 composite