-
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
Better basePath
support
#914
Comments
This is going to be a very wordy reply, so I apologize in advance! Originally, our goal was to support both top-down and bottom-up development of a REST application in LoopBack 4. In the case of top-down, we're referring to either providing the whole spec via As we continued this approach, some community members (both externally and within IBM) commented on how they found the top-down approach to be cumbersome and ugly.
Given that feedback, combined with the issue of having far fewer full-time developers on LoopBack as we did last year, we had to begin prioritizing support for features with the goal of an MVP in mind. As a part of our MVP push, we're focusing on bottom-up support instead, though updating the existing documentation is a part of our backlog. With respect to the |
@strongloop/loopback-devs What's everyone's take on the current documentation? We could:
|
I think the controller class decorator People now can specify a And maybe we should:
Then the By relative base path I mean:
here |
I think we should create the fix for the base path first and then see about creating controller-specific base paths, but there's no reason why we can't create an issue for it now. With respect to the current We've already got a significant case of doc-rot going on here; the last thing I want is to leave in decorators that don't do anything, or worse, do things in an incomplete/wrong fashion. |
@kjdelisle I am already doing some change to the basePath in PR: I can address the issue you created in #918, I just don't think we need another PR for it.
Did I say anything that prevents you from creating new issue lol ? I agreed with you: "As the discussion above said, basePath should be provided in restServer's config.", just I believe some code in the restServer accepts |
oh ok, I didn't notice that is a PR, I thought it's just an issue.. |
Last time we were discussing top-down approach, we agreed to add a note to related doc pages. See #796 Docs: add a note about top-down approach not being ready yet |
Thanks for taking this so seriously! It's been great to see. One more thing to note -- when requesting the swagger/openapi documents, we would like those to follow the basepath as well. So if we're rooted at |
For now, we'll have to delay the fix to post-MVP given the current timeline we've set. @jannyHou will be landing a PR in the near-future that will alter how it's working under the hood so I've closed my own PR. As an alternative, if you'd like to make a pull request once the OpenAPI spec changes land, I could review/land it. |
related to #918 |
@nabdelgadir , could you please help with the grooming? Thanks! |
Current state:
Acceptance Criteria
|
I believe this is a regression introduced by 912bece. The code generating My commit changed the way how |
Currently, you can set a
spec.basePath
at the top-level of your spec, but it does not cascade down as expected to all the endpoints in your app. To get abasePath
to have an effect, we must pass in a partialControllerSpec
for each controller, negating the benefits of describing something with a base path. I'd expect each endpoint under the primary document to inherit this base path.In addition, no amount of config will seem to let us put the swagger docs under this
basePath
as well, since it's hardcoded inrest-server.ts
to only serve from the root.The
basePath
at the top-level openapi spec seems like a good candidate for defining this, but also maybe providing a general "mount path" for the application, that it's aware it's not at the context root.The only workaround we see currently is to have a rewriting proxy server that will modify requests coming in to remove a context root, and to modify outgoing requests to add a context root, but this seems ... inefficient :)
The text was updated successfully, but these errors were encountered: