carlansley / swagger2-koa

Koa 2 middleware for swagger2
MIT License
99 stars 28 forks source link

Accept header for simple GET request sent with text/plain even if application/json is set #13

Closed croraf closed 7 years ago

croraf commented 7 years ago

I described the issue in depth here:

https://github.com/swagger-api/swagger-ui/issues/3282

swagger2-koa version 0.0.36. UPDATE: I didn't use swagger2-koa router, but validate and ui functions.

croraf commented 7 years ago

I think I deleted typedarray-to-buffer library that was installed outside of node_modules, perhaps this caused the issue. Will check today later. If you can test GETwith Accept: application/json works properly on swagger2-koa version 0.0.36.

croraf commented 7 years ago

I think I found the cause. I used the following order:

app.use(validate(document));
app.use(ui(document));

app.use(router.routes());

Instead the following is correct:

app.use(validate(document));

app.use(router.routes());

app.use(ui(document));

I will test once more later and close the issue. Can you confirm the latter is the correct way?

carlansley commented 7 years ago

Yes, the ui middleware should come last.