Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Fix headers parsing #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix headers parsing #4

wants to merge 1 commit into from

Conversation

maxenced
Copy link

With raml like :

/test:
  get:
    description: test

    responses:
        200:
          headers:
            Access-Control-Allow-Origin:
              example: "*"
          body:
            application/json:
...

current version of raml-mock-service fails with :

TypeError: response.headers.forEach is not a function
    at handler (/usr/lib/node_modules/raml-mock-service/raml-mock-service.js:104:24)
    at /usr/lib/node_modules/raml-mock-service/node_modules/osprey-resources/osprey-resources.js:58:20
    at Array.forEach (native)
    at createResource (/usr/lib/node_modules/raml-mock-service/node_modules/osprey-resources/osprey-resources.js:57:13)
    at /usr/lib/node_modules/raml-mock-service/node_modules/osprey-resources/osprey-resources.js:33:7
    at Array.forEach (native)
    at createResources (/usr/lib/node_modules/raml-mock-service/node_modules/osprey-resources/osprey-resources.js:32:15)
    at ospreyResources (/usr/lib/node_modules/raml-mock-service/node_modules/osprey-resources/osprey-resources.js:17:10)
    at ospreyMockServer (/usr/lib/node_modules/raml-mock-service/raml-mock-service.js:20:10)
    at createServer (/usr/lib/node_modules/raml-mock-service/raml-mock-service.js:34:11)

This is because response.headers is a hash, not an Array.
This commit fix this by iterating correctly through the hash.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants