Giter VIP home page Giter VIP logo

openapi-mock's Introduction

OpenAPI Mock

CLI utility to start a mock server based upon a Swagger/OpenAPI JSON or YAML spec file.

Uses swagger-node-runner and sway.

Install

npm install -g openapi-mock

Usage

Usage: openapi-mock [options] <spec>


Options:

  -V, --version        output the version number
  -m, --mock <dir>     path to mock directory
  -c, --config <file>  path to config file
  -p, --port <n>       port to start the mock server on
  -h, --help           output usage information

openapi-mock's People

Contributors

penx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

openapi-mock's Issues

Expand all arrays regardless of depth

Hi,

Loving openapi-mock! One thing I've noticed is that if you have an array at the depth of 2 then the response from the server will show [Array] instead of the array values.

For example:

{ name: 'consequat et amet',
  selections: [ { markets: [Array] } ] }

Ideally the selections.markets array (and any other arrays at deeper depths) would be expanded also so the properties in there can be parsed.

Yaml used in example:

swagger: '2.0'
info:
  description: Card Data Service
  version: 1.0.0
  title: Card Data Service
  termsOfService: 'http://swagger.io/terms/'
  contact:
    email: [email protected]
  license:
    name: MIT
host: 'localhost:10010'
basePath: /
schemes:
  - http
paths:
  '/cards':
    get:
      summary: Get Cards
      description: Get all data necesary
      operationId: getCards
      produces:
        - application/json
      responses:
        '200':
          description: successful operation
          schema:
            $ref: '#/definitions/Card'
definitions:
  Card:
    type: object
    required:
        - name
        - selections
    properties:
      name:
        type: string
        example: Example Card
      selections:
        type: array
        items:
          $ref: '#/definitions/CardSelection'
  CardSelection:
    type: object
    required:
      - markets
    properties:
      markets:
        type: array
        items:
          $ref: '#/definitions/market'
  market:
    type: object
    required:
      - id
    properties:
      id:
        type: string
        example: 1

CLI

Create a CLI:

Usage: openapi-mock [options] [spec]
       openapi-mock -m ./api/mocks  ./api/swagger/spec.yaml

Options:
  -m, --mock=dir              path to mocks folder
  -c, --config=file           path to config file

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Documentation for openapi-mock

Hello!

I'm considering using openapi-mock as a test tool for client side API testing and wondering if there is any documentation or samples available? I'd like to create mock servers based on my OpenApi yamls and test positive and negative cases. The help screen indicates options for configuration and mock_dir and I assume those are where the input data/code for processing various requests would reside.

Any help using the tool would be greatly appreciated!

Thanks
Frank

absolute path swagger

I see in your code, you set absolute path petstore.json then function -m on console not useful.

function createApp({ spec = path.join(__dirname, './example/spec/petstore.json'), mock, config = path.join(__dirname, '.'), port = process.env.PORT || 10010} = {}) { var config = { configDir: config, swaggerFile: spec, appRoot: __dirname, bagpipes: { _router: { mockControllersDirs: [mock] } } };

spec = path.join(__dirname, './example/spec/petstore.json'),

swaggerFile: spec,

Watch mode

Watch spec file and restart on change

Support for OpenApi3.0?

Hello!

Are there any plans for openapi-mock to support OpenApi3.0 documents?

Thanks
Frank

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.