-
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
feat(booter-lb3app): process generated OpenApiSpec of lb3 app #3623
Conversation
@derdeka Thank you for the patch!
Do these fixes apply to most use cases? If so, we should fix them in the booter implementation itself. I'm open to the idea to allow Please add some tests. |
Thank you @derdeka for the pull request.
I agree with what Raymond wrote above - it would be best to fix the code that's generating OpenAPI spec, so that no further post-processing is needed. It makes me wonder - are you using Swagger with your LB3 application? Is that swagger spec correct?
I am not sure how easy would be to support this use case at loopback-swagger and/or the booter level. Your proposal to allow applications to contribute a custom post-processing function (handler) looks like a great solution 👍 Can we find a shorter name for |
7391fa1
to
74556ee
Compare
3f29d8d
to
d8e4a84
Compare
I've renamed and added a simple test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
@raymondfeng I'd like to get your approval too. Could you please land this patch if it looks good to you too?
@@ -128,6 +132,7 @@ export interface Lb3AppBooterOptions { | |||
path: string; | |||
mode: 'fullApp' | 'restRouter'; | |||
restApiRoot: string; | |||
specTransformer?: (spec: OpenApiSpec) => OpenApiSpec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good to have specTransformer
to be synchronous function as a starting point. We should consider generalizing the idea:
- Allow asynchronous transformation
- Create an extension point for spec transformers/processors to transform OpenAPI specs generated from controller metadata. For example, our authentication/authorization packages may want to add more information to the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note this transformer is applied only for LB3 applications imported to LB4.
While migration from lb3 to lb4 I had several issues with the converted openapi spec of my lb3app, e.g.:
We solved this by post processing the generated openapi spec before it gets published into lb4.
If you think this is the way to go, we can add some tests.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated