airtasker/spot

Ability to extend class with some methods

Opened this issue · 0 comments

ofw commented

It would be great to have ability to inherit some base behavior.
For example, when each HTTP endpoint can return 400 and 500 error with a known schema.

Now those methods are not generated in openapi file.

Example:

class BaseEndpoint {

    @response({ status: 400 })
    badRequest(@body body: BadRequestError) { }

    @response({ status: 500 })
    internalError(@body body: InternalError) { }
}

@endpoint({
    method: "POST",
    path: "/a"
})
class EndpointA extends BaseEndpoint {
    @request
    request(@body body: ReqA) { }
}

@endpoint({
    method: "POST",
    path: "/b"
})
class EndpointB extends BaseEndpoint {
    @request
    request(@body body: ReqB) { }
}