mocks-server / main

Node.js mock server running live, interactive mocks in place of real APIs
https://www.mocks-server.org
Apache License 2.0
281 stars 14 forks source link

[object Object] header in OpenApi mocks #489

Open vaiil opened 4 months ago

vaiil commented 4 months ago

Describe the bug When I provide example for header, mocks-server produces response with header value [object Object]

To Reproduce Create mocks for this openapi spec:

openapi: 3.0.3
info:
  title: test
  version: 0.0.1
paths:
  /products:
    get:
      tags:
        - products
      summary: Get products
      responses:
        '200':
          description: Get field list
          headers:
            X-Total-Count:
              schema:
                type: integer
                format: int64
                example: 5
              description: Total count of products
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
              examples:
                simple:
                  value:
                    - id: 1
                      name: "IPhone 11"
                    - id: 2
                      name: "Iphone 12"

Start server

Check the response header:

$ curl -vs http://localhost:3100/products 2>&1  | grep X-Total
#OUTPUT: < X-Total-Count: [object Object]

Expected behavior Get the value from example