-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add OpenAPI enhancer service in @loopback/rest #4380
Comments
@strongloop/loopback-next @strongloop/loopback-maintainers @mschnee Call for contribution: Happy contributing! |
#4539 related pull. |
Hi @jannyHou I've had a cursory look over the code and I do have a query on how to proceed with implementation. How would I handle the sync call to an async function(is there an example to study?) The sync example above: getApiSpec (requestContext?: RequestContext): OpenApiSpec {
// ...other code
spec = this.OASEnhancer.applyEnhancerByName('authorization-bearer');
} The code in async applyEnhancerByName(name: string): Promise<OpenApiSpec> {
const enhancer = await this.getEnhancerByName(name);
if (enhancer) this._spec = enhancer.modifySpec(this._spec);
return this._spec;
} I've not really dealt with this issue before as I could use await. Is there is a particular trick to this implementation? EDIT: I'll proceed by making getApiSpec async. |
PR in progress: #4554 |
add openapi spec enhancer to rest server impl. loopbackio#4380 Signed-off-by: Douglas McConnachie <[email protected]>
add openapi spec enhancer to rest server impl. loopbackio#4380 Signed-off-by: Douglas McConnachie <[email protected]>
add openapi spec enhancer to rest server impl. loopbackio#4380 Signed-off-by: Douglas McConnachie <[email protected]>
add openapi spec enhancer to rest server impl. loopbackio#4380 Signed-off-by: Douglas McConnachie <[email protected]>
add openapi spec enhancer to rest server impl. loopbackio#4380 Signed-off-by: Douglas McConnachie <[email protected]>
add openapi spec enhancer to rest server impl. loopbackio#4380 Signed-off-by: Douglas McConnachie <[email protected]>
add openapi spec enhancer to rest server impl. #4380 Signed-off-by: Douglas McConnachie <[email protected]>
Closing as done. |
Suggestion
This is a follow-up story for #4258, after creating the oai enhancer service as extension point, we should add the service in
@loopback/rest
module so that other enhancers could register and contribute OpenAPI specs into the application(server).Use Cases
Inside function
getApiSpec()
, you can apply an enhancer like:Examples
Same as use cases
Acceptance criteria
add an
OASEnhancerService
in the rest server, as how it has other properties like_requestHandler
.add tests for registering and invoking enhancers
(Stretch Goal, feel free to open new stories)if any existing spec contribution code in https://github.com/strongloop/loopback-next/blob/master/packages/rest/src/rest.server.ts#L702 should be organized into enhancers, then refactor them into enhancers
The text was updated successfully, but these errors were encountered: