ClearC2 / headlamp

Generate express api documentation automagically
2 stars 1 forks source link

can we have multiple responses for different query params and same url? #37

Closed Phalguna2125 closed 3 years ago

Phalguna2125 commented 3 years ago

I have to modify the response based on query params but the response is giving back the same for different query param/different files. Is this possible?

dadamssg commented 3 years ago

@Phalguna2125 yes! you can use the response key(not responses with an "s").

export default {
  path: '/people',
  methods: ['GET', 'POST', 'PUT'],
  response: (req, res) => {
    return res.json(/* something based on the req object */)
  }
}

The only downside to this is you don't have have a mock response in the headlamp UI if you don't also fill out the responses.