dhuan_
https://dhuan.github.io/mock/latest/examples.html Command line utility that lets you build APIs with just one command.
https://github.com/dhuan/dop JSON/YAML manipulation with AWK style approach.
I've built a data transforming tool powered by Lua[1] and would definitely like to benefit from an general purpose api/library like Lute.
https://dhuan.github.io/mock/latest/examples.html
^Command line utility that lets you build APIs with just one command.
^JSON/YAML manipulation with AWK style approach.
https://dhuan.github.io/mock/latest/examples.html
^Command line utility that lets you build APIs with just one command.
^JSON/YAML manipulation with AWK style approach.
Show HN: Dop, Awk-like processing for JSON/YAML/TOML with Lua
dop reads JSON, YAML, or TOML from stdin, walks the structure field by field, and lets you transform values with Lua. It can also query nested paths and convert between formats.It weights just 800kb and you don't need Lua installed in your pc.A few examples:echo '{"list":[1,2,3]}' | dop -e ' if type(VALUE) == "number" then set(VALUE * 2) end ' # => {"list":[2,4,6]}echo...
this and other reasons is why I built: https://github.com/dhuan/dop
https://dhuan.github.io/mock/latest/examples.html#youtube-do...
Mock on the other hand is an actual API creation utility with which you can define endpoints, execute some logic for each endpoint and then return some data to the client. There are other similar features which are covered in the user guide.
Mock is not: - A tool for API Specs or documentation - A GUI tool.
I admit explaining the usefulness of this tool is not the easiest thing.
Any feedback is welcome!
That's true, it's not a very unique name. I started building it, but only months later I thought of making it public. And then never thought of renaming it.
> What's the main motivation for creating this tool?
Similar tools exist out there for sure, but they are either complex (more than I wish they'd be) or somehow require you to use a specific programming languages. Mock lets you accomplish this without telling you which language you should use.
Also if you're using mock inside CI pipelines, it also helps the fact that you can just download a executable tool that does not require you the java platform or any other dependency.
> How hard/easy is it to make responses dynamic, i.e. to use something from the request data like query/path param or a body to execute function instead of hardcoding the response
With mock you can use shell scripts as "request handlers". With that said, capturing a query param or a JSON field from the request body is as simple as:
> $ USER_NAME=$(mock get-payload user.name)
> $ SOME_QUERY_STRING_PARAM=$(mock get-query foo)
You can see more of this topic here: https://dhuan.github.io/mock/shell_scripts.html
> I feel like every programming language have similar tool already - WireMock for Java etc. Why should people switch?
True. If people are happy with these tools and needing to use java (or any other lang the tool pulls you into), then there's not much reason to switch.
Mock – An API creation and testing utility: Examples
the process of creating APIs for testing and automation should be as easy possible. the tools that exist nowadays aren't good enough, they require you to use their programming language of choice or complex procedures for a task that should be simple. I built mock to try to solve that and still continue to maintain it.
the process of creating APIs for testing and automation should be as easy possible. the tools that exist nowadays for this purpose aren't good enough IMHO, which led me to build it.
the process of creating APIs for testing and automation should be as easy possible. the tools that exist nowadays aren't good enough, they require you to use their programming language of choice or complex procedures for a task that should be simple. I built mock to try to solve that and still continue to maintain it.
Show HN: Mock v1.4.3 – create APIs using just shell scripts
mock is an API utility - it lets you:- define API routes easily through API configuration files or through command-line parameters. - use shells scripts as response handlers. Or any other type of program can act as response handlers. - test your API - make assertions on whether an endpoint was requested.
After some time, I decided to open-source it:
With mock you can set up backend APIs completely from configuration files or even from command-line parameters - such as
$ mock serve --port 3000 --route 'say_hi/{name}' --method GET --response 'Hello world! My name is ${name}.' --route "what_time_is_it" --method GET --exec 'printf "Now it is %s" $(date +"%H:%M") > $MOCK_RESPONSE_BODY'