yasm

0.1.2 • Public • Published

What is this?

YASM(Yet Another Swagger Mocker) is a stupid simple cli tool for generating a http server from a swagger contract. It works by extracting additional metadata from your swagger file and uses that to respond to requests. You can additionally pass custom generators to the cli that, in effect, controls how the mock server generates data.

How do i get it?

npm install yasm -g

How do i use it?

Given the following v3 swagger snippet with responses definition

"responses"{
  "200": {
    "description": "User Details",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties":{
            "name": {
              "type":"string"
              "faker": "random.findName"
            },
            "age": {
              "type": "number"
              "faker": "random"
            }
          }
          "required":["name", "age"]
        }
      }
    }
  }
}

Executing the following

$ yasm serve --port=3000 --file=/path/to/swagger/file.json

will give you back

{
  "name":"Daniel",
  "age": "21"
}

CLI Options

  • --port- Port to bind mock server on (Omitting this cause the cli to pick a random free port to use)
  • --file - File containing swagger specification
  • --url - Url to download the swagger file
  • --include-optional - Will include optional properties defined in the swagger file as part of the response. Defaults to false
  • --generator - Specifies a generator custom script.
  • --prefer-example - Uses the examples object as response
  • --prefer-faker - Uses fake data as response

Readme

Keywords

Package Sidebar

Install

npm i yasm

Weekly Downloads

1

Version

0.1.2

License

ISC

Unpacked Size

19.2 kB

Total Files

9

Last publish

Collaborators

  • bigmeech