Skip to content

MathObsessed/openapi_mock_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Openapi Spec Mock Server Example

This project demonstrates how to implement a mock server based on an Openapi spec.

Install required dependencies:

npm install

Generate Openapi specs:

npm run gen

Lint specs:

npm run lint

Start mock servers (each command is a foreground process, so you're going to need several terminals):

npm run v1
npm run v2

You can access mock servers on http://127.0.0.1:4010 for v1 and on http://127.0.0.1:4011 for v2.

Test requests

First start both APIs (v1 and v2). Now these examples demonstrate different aspects of mock server responses:

  • Simple call will return a set of randomly generated objects
    curl -L -X GET 'http://127.0.0.1:4010/products'
    
  • A call with Prefer header and a specific example name will return that example
    curl -L -X GET 'http://127.0.0.1:4010/products' \
    -H 'Prefer: example=three_products'
    

Info

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages