Forum Discussion

NinjaPanda47's avatar
NinjaPanda47
New Member
2 years ago

How to define ctx.state with open-api?

I'm currently trying to document one of our APIs using open-api per company security requirement but I am unable to get my api end points to work in the open-api.  The problem I'm running into is that we use the koa library for our router and we use ctx.state for our permissions check via middleware.  There's no documentation on how to define ctx.state in open-api.  Currently only routes that do not require permissions check are working.  There's only options for ctx.query and ctx.params and ctx.request.body.  How would I define ctx.state on open-api so the routes can be tested via the open-api doc?  Here's link to the koa library and the guide I used to incorporate the open-api with our API.

 

https://github.com/koajs/koa/blob/master/docs/api/context.md

https://ljn.io/posts/swagger-for-a-koa-api

No RepliesBe the first to reply