Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mockModeNoCallback option and controller cache #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

moander
Copy link

@moander moander commented Aug 5, 2016

Please see my question about context.headers[] before merging.

  • mockModeNoCallback config option. Swagger examples show res.end() in the controllers while mock mode use cb(). This makes a huge difference for projects using custom fitters
    after the router.
  • Return content-type header on Accept: /
  • Simple default content-type detection
  • Place auto-generated mock controller function in cache
  • Made logging a bit more verbose
  • ignoreMissingHandlers option as described in swagger-tools router docs

Sorry for the bundled pull request ;)

mockModeNoCallback config option makes it possible for mockMode to
behave more like the real deal.

swagger examples show res.end() in the controllers while mock mode use
cb(). This makes a huge difference for projects using custom fitters
after the router.
cb(new Error(util.format('No controller found for %s in %j', controllerName, controllersDirs)));
}
};
response.setHeader('Content-Type', mimetype);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can someone please confirm if it's ok to use response.setHeader instead of context.headers[]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best confirmation you'll get is a test that runs this code

@coveralls
Copy link

coveralls commented Aug 5, 2016

Coverage Status

Coverage decreased (-1.05%) to 95.902% when pulling 533a18d on moander:feature/router-stuff-1 into cc89cb2 on theganyo:master.

options.ignoreMissingHandlers: [boolean] When false (default), a 500 is
returned when a handler cannot be found. When true, we will ignore the
missing handler and send the request downstream.
@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage decreased (-1.5%) to 95.447% when pulling a944384 on moander:feature/router-stuff-1 into cc89cb2 on theganyo:master.

@theganyo
Copy link
Collaborator

theganyo commented Aug 7, 2016

Thanks for your contribution. Would you be able to provide any tests to verify your work?

@osher
Copy link
Contributor

osher commented Nov 8, 2016

Swagger examples show res.end() in the controllers while mock mode use cb(). This makes a huge difference for projects using custom fitters
after the router.

I think it's a deceiving problem, we need to fix these examples.
In this sense, they just show what not to do...

The fact that the examples assume there is no handler down the pipeline after them is not known to readers - hence the deception

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

Successfully merging this pull request may close these issues.

None yet

4 participants