Skip to content

Measy/swagger-express-middleware-with-chance

 
 

Repository files navigation

Swagger Express Middleware of chancejs mock version

Swagger middleware and mocks for Express.js

Fork from swagger-express-middleware

Mock data using swagger-mock-parser

This Swagger middleware support random mock data while response schema has no example or default defined.

###Example

paths
  /api/mis/info:
    get:
      summary: Product Types
      description: |
        query mis
      parameters:
        - name: queryString
          in: query
          required: true
          type: string
          description: mis info
      responses:
        '200':
          description: mis user list
          schema:
            $ref: '#/definitions/MisInfoResult'
definitions:
  MisInfo:
    type: object
    properties:
      id:
        type: integer
        format: int32
        description: key
      login:
        type: string
        description: id
      name:
        type: string
        description: name
  MisInfoResult:
      type: object
      properties:
        code:
          type: integer
          format: int32
          description:
        message:
          type: string
        data:
          type: array
          items:
            $ref: '#/definitions/MisInfo'

When you use this example and visit '/api/mis/info' ,you will get

{
  "code": 123124,
  "message": "ORJ78pLt1",
  "data": [
    {
      "id": 6415711236784129,
      "login": "%ORJ78pLt1@qEAv$1A",
      "name": "syBQXMu2!n"
    },
    {
      "id": -571708163489791,
      "login": "Pu)HS%#1LzxEO",
      "name": "Mz[ith3o"
    },
    {
      "id": 2581669118738433,
      "login": "#Ne6slM6cW*acwlG",
      "name": "p)0HAWX6TF^#%%gQg6"
    },
    {
      "id": -8350341267455999,
      "login": "9fZEKmYQ3U^fDV",
      "name": "lZ9Cv@8yoS"
    },
    {
      "id": 2669672256241665,
      "login": "ZQpENhB!nJ9C7Ap^Au",
      "name": "mzWoEQk[EG[yLWy"
    }
  ]
}

The mock data will generate randomly each time by chanceJS,Though it has no meaningful. I suggest you use swagger-mock-file-generator to save a json file with example schema which generated by chancejs. It supports this project or swagger-express-middleware project.

License

Swagger Express Middleware is 100% free and open-source, under the MIT license. Use it however you want.

About

Swagger middlware and mocks for Express.js and Node

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%