Comments (2)
This is an example for my application.
# upload.yaml
/cdn/upload:
post:
summary: Upload file to cdn
consumes:
- "multipart/form-data" # required
x-oai-controller:
- file: system/upload
handler: parser
- file: system/upload
handler: upload
parameters:
- name: file
in: formData # required
type: file # required
description: file
responses:
default:
description: Response model
schema:
$ref: "#/definitions/ResponseModel"
// system/upload.js
import busboy from 'koa-busboy';
const parser = busboy();
async function upload(ctx, next) {
{your code...}
const files = ctx.request.files;
{your code...}
}
export {
parser,
upload,
};
from koa-oai-router.
Thanks. I'm probably missing somethin obvious, but I simply copied the x-oai-controller
inside my route and created /ctrl/system/upload.js
where /ctrl
is the path
for koa-oai-router-autoloader
But I have this error message:
router boot error: Error: args must be string or object, not undefined
at MiddlewarePlugin.loadHandler (/vagrant/app/node_modules/koa-oai-router-middleware/src/middleware.js:47:13)
at _.each (/vagrant/app/node_modules/koa-oai-router-middleware/src/middleware.js:30:26)
at arrayEach (/vagrant/app/node_modules/lodash/lodash.js:516:11)
at Function.forEach (/vagrant/app/node_modules/lodash/lodash.js:9344:14)
at MiddlewarePlugin.handler (/vagrant/app/node_modules/koa-oai-router-middleware/src/middleware.js:29:7)
at MiddlewarePlugin.<anonymous> (/vagrant/app/node_modules/koa-oai-router/lib/plugin.js:151:29)
at Generator.next (<anonymous>)
at step (/vagrant/app/node_modules/koa-oai-router/lib/plugin.js:25:191)
at /vagrant/app/node_modules/koa-oai-router/lib/plugin.js:25:361
I'm using these koa plugins:
"@koa/cors": "^2.2.2",
"koa": "^2.6.1",
"koa-bodyparser": "^4.2.1",
"koa-busboy": "^1.2.0",
"koa-graceful-shutdown": "^1.1.0",
"koa-oai-router": "^2.0.3",
"koa-oai-router-autoloader": "^1.0.2",
"koa-oai-router-middleware": "^1.1.2",
"koa-oai-router-parameters": "^1.1.2",
"koa-pino-logger": "^2.1.3",
Thanks for your help
EDIT
Just found out that I need to put middleware: "/ctrl"
in the new Router
configuration. But I still have an error: without x-oai-controller
, my controller is called (with a simple console.log). But with it, the route returns a 404 and I can't figure out why.
EDIT 2
Ok, I found out that I was totally mixing my paths. Now it is alright and I have my files, thanks a lot!
from koa-oai-router.
Related Issues (20)
- support custom format repsonse when a request's parameters verify failed
- Upgrade swagger UI HOT 5
- [Question] 'controllerDir' and 'x-oai-controller' name choice. HOT 2
- Add middlewareDir and x-oai-middleware alias HOT 1
- Support allOf to split paths into multi files HOT 1
- Not getting parameter from path HOT 1
- ctx.renderSwaggerApiExplorer is undefined HOT 3
- Protected routes HOT 4
- [Question] wrap every route into a try catch HOT 3
- Please publish 1.1.2 to npm HOT 1
- support boolean type verification in url query object HOT 3
- Support for OAI v3 HOT 9
- Validator fails for single value for arrays HOT 2
- API Explorer shows Petstore instead of custom API HOT 3
- Unterminated Promise HOT 4
- unable to mount two routers to koa HOT 2
- [Question] Do you have a roadmap ? HOT 2
- What's wrong with this api path? HOT 2
- query schema at least has one 'required' item HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa-oai-router.