Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to generate specification in mixin abstract classes #115

Open
TechQuery opened this issue Sep 15, 2022 · 0 comments
Open

failed to generate specification in mixin abstract classes #115

TechQuery opened this issue Sep 15, 2022 · 0 comments

Comments

@TechQuery
Copy link

Expect

@epiphone I want to reduce the Source-code Size, so I wrote a Controller Abstract Class mixin:

import { Constructor } from 'web-utility';
import { Post, Body } from 'routing-controllers';
import { ResponseSchema } from 'routing-controllers-openapi';

export function Controller<M>(Model: Constructor<M>) {
    abstract class BaseController {
        @Post()
        @ResponseSchema(Model)
        // @ts-ignore
        createOne(@Body() data: Model) {
            // ORM logic
        }
    }
    return BaseController;
}

Actual

But it thrown an error at:

/** Return full Express path of given route. */
export function getFullExpressPath(route: IRoute): string {
const { action, controller, options } = route
return (
(options.routePrefix || '') +
(controller.route || '') +
(action.route || '')
)
}

TypeError: Cannot read property 'route' of undefined
    at getFullExpressPath (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected][email protected]\node_modules\routing-controllers-openapi\src\generateSpec.ts:18:17)
    at getFullPath (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected][email protected]\node_modules\routing-controllers-openapi\src\generateSpec.ts:27:31)
    at D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected][email protected]\node_modules\routing-controllers-openapi\src\generateSpec.ts:77:6
    at Array.map (<anonymous>)
    at getPaths (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected][email protected]\node_modules\routing-controllers-openapi\src\generateSpec.ts:76:29)
    at Object.getSpec (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected][email protected]\node_modules\routing-controllers-openapi\src\generateSpec.ts:291:12)
    at routingControllersToSpec (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected][email protected]\node_modules\routing-controllers-openapi\src\index.ts:28:16)
    at createSwagger (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected]\node_modules\koagger\dist\Swagger.js:16:77)
    at createAPI (D:\Work\idea2app\REST-Node-ts\node_modules\.pnpm\[email protected]\node_modules\koagger\dist\index.js:10:44) 
    at Object.<anonymous> (D:\Work\idea2app\REST-Node-ts\source\controller\index.ts:10:53)

Reproduce code

idea2app/REST-Node-ts#1

Environment

Software Version(s)
Node 14.19.1
PNPM 7.11.0
Operating System Windows 10 Pro 21H2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant