curldoc
v0.0.2
Published
Executable Web API document format using the curl command
Downloads
2
Readme
curldoc
curldoc is a simple executable Web API document format using the curl command.
The CLI Application of curldoc behave a HTTP mock server from a markdown file of Web API document.
You can create a mock server with such as the following markdown document.
Usage
CLI
# Install CLI-app
$ npm install --global curldoc
# Download sample document
$ curl -sL https://raw.githubusercontent.com/yammerjp/curldoc/main/example/helloworld.md > helloworld.md
# Start mock server
$ curldoc helloworld.md
# Usage:
# $ curldoc (--port <TCP port>) <markdown file paths ... >
Library
- Install the npm package 'curldoc' with
npm i curldoc
for your project - Create API document (example)
- Write TypeScript/JavaScript such as the following code
import curldoc from 'curldoc'
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
async function main() {
const server = await curldoc.server(3000, [ 'path/to/markdown/file.md' ])
await wait(1000)
server.close()
console.log('closed')
}
main()
Support curl options
You can use following the options in a markdown's codeblock 'curldoc-request'.
--header
,-H
... specify http request headers--data-raw
... specify a http request body--request
,-X
... specify a http request method
If you want to use other options, please contribute to the repository. (curl options are processed in /src/documentProcessor/curlOptionHandlers.ts)
LICENSE
MIT