krakenjs / swaggerize-express

Design-driven apis with swagger 2.0 and express.
Other
354 stars 81 forks source link

How to use the generated Data Providers? #123

Open asherrecv opened 7 years ago

asherrecv commented 7 years ago

I (*) am trying to get my head around on how to use the generated data providers. I see for every modeled response code a separate function. In the corresponding handler I see that the data provider for the standard response (i.e. HTTP-200) is called.

Now let's say I want to make a database call and return a HTTP-404 if the data base item was not found. What is the intended way to do this? I know that I can put logic into the handlers, but there must a reason why those providers a generated, right?

(*) apparently I'm not the only one: http://stackoverflow.com/questions/41567487/how-am-i-intended-to-use-handler-and-dataprovider-in-swaggerize-express