-
Notifications
You must be signed in to change notification settings - Fork 57
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: Support basePath
in options-per-service for openapi generator - Option 2
#5247
Conversation
…hub.com:SAP/cloud-sdk-js into feat/openapi-support-basePath-optionsPerService
…ud-sdk-js into feat/openapi-support-setBasePath
…ud-sdk-js into feat/openapi-support-setBasePath
Co-authored-by: Deeksha Sinha <[email protected]>
Co-authored-by: Deeksha Sinha <[email protected]>
Co-authored-by: Deeksha Sinha <[email protected]>
…ud-sdk-js into feat/openapi-support-setBasePath
packages/openapi-generator/src/file-serializer/__snapshots__/api-file.spec.ts.snap
Outdated
Show resolved
Hide resolved
I have addressed all review comments.
{ | ||
method: 'get', | ||
middleware: [], | ||
url: 'base/path/to/service/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.
@tomfrenken Fyi since it relates to some of your code changes like two years ago. Here without a leading slash is the same behaviour as in OData, where remove (leading/trailing) slashes functions were used at almost each and every step to ensure no slashes at all. But it feels kind inconsistent to me because without setting the base path, we use and probably also recommend adding a leading slash at the path.
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.
Overall LGTM. Thanks for this nice contribution.
Be sure to add this to v4.
… - Option 2 (#5247) * chore: append basePath to path pattern in openapi generator * chore: switch to using removeSlashes from util * chore: add additional test * chore: check-public-api change * Changes from lint:fix * chore: update test * chore: adjust all tests * chore: fix codeQL warning * Changes from lint:fix * chore: add changeset * chore: cleanup tests * feat: extend openapi request builder for basePath * chore: introduce setBasePath * feat: introduce _defaultBasePath to the generated files * chore: fix order of parameters with intro of basepath * chore: fix tests * chore: add setBasePath * chore: fix failing e2e test * Changes from lint:fix * chore: cleanup path * Changes from lint:fix * chore: adjust test * Changes from lint:fix * chore: switch to using undefined for default basePath value * chore: cleanup test * chore: update changeset * chore: adjust changeset * chore: fix unit test * chore:cleanup * chore: fix test * chore: cleanup changesets * fix: integration test * chore: fix path * chore:fix path * chore: remove dead code * chore: review comment * Update .changeset/chilled-flowers-hide.md Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/openapi/src/openapi-request-builder.ts Co-authored-by: Deeksha Sinha <[email protected]> * chore: address review comments * chore: revert update to removeSlashes utility * Changes from lint:fix * chore: address review comments * chore: tests fix * chore: adjust tests * chore: address review comments * Changes from lint:fix * fix: begin all paths using '/' * chore: address review comments * Update .changeset/chilled-flowers-hide.md Co-authored-by: Deeksha Sinha <[email protected]> * Update .changeset/chilled-flowers-freeze.md Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/util/src/remove-slashes.spec.ts Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/util/src/remove-slashes.spec.ts Co-authored-by: Deeksha Sinha <[email protected]> * chore: address review comments * Changes from lint:fix * chore: add review changes * chore: address review comments * chore:address review comments * chore: address review comments * chore: release note fix --------- Co-authored-by: cloud-sdk-js <[email protected]> Co-authored-by: Junjie Tang <[email protected]> Co-authored-by: Deeksha Sinha <[email protected]>
… - Option 2 (#5247) * chore: append basePath to path pattern in openapi generator * chore: switch to using removeSlashes from util * chore: add additional test * chore: check-public-api change * Changes from lint:fix * chore: update test * chore: adjust all tests * chore: fix codeQL warning * Changes from lint:fix * chore: add changeset * chore: cleanup tests * feat: extend openapi request builder for basePath * chore: introduce setBasePath * feat: introduce _defaultBasePath to the generated files * chore: fix order of parameters with intro of basepath * chore: fix tests * chore: add setBasePath * chore: fix failing e2e test * Changes from lint:fix * chore: cleanup path * Changes from lint:fix * chore: adjust test * Changes from lint:fix * chore: switch to using undefined for default basePath value * chore: cleanup test * chore: update changeset * chore: adjust changeset * chore: fix unit test * chore:cleanup * chore: fix test * chore: cleanup changesets * fix: integration test * chore: fix path * chore:fix path * chore: remove dead code * chore: review comment * Update .changeset/chilled-flowers-hide.md Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/openapi/src/openapi-request-builder.ts Co-authored-by: Deeksha Sinha <[email protected]> * chore: address review comments * chore: revert update to removeSlashes utility * Changes from lint:fix * chore: address review comments * chore: tests fix * chore: adjust tests * chore: address review comments * Changes from lint:fix * fix: begin all paths using '/' * chore: address review comments * Update .changeset/chilled-flowers-hide.md Co-authored-by: Deeksha Sinha <[email protected]> * Update .changeset/chilled-flowers-freeze.md Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/util/src/remove-slashes.spec.ts Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/util/src/remove-slashes.spec.ts Co-authored-by: Deeksha Sinha <[email protected]> * chore: address review comments * Changes from lint:fix * chore: add review changes * chore: address review comments * chore:address review comments * chore: address review comments * chore: release note fix --------- Co-authored-by: cloud-sdk-js <[email protected]> Co-authored-by: Junjie Tang <[email protected]> Co-authored-by: Deeksha Sinha <[email protected]>
… - Option 2 (#5247) * chore: append basePath to path pattern in openapi generator * chore: switch to using removeSlashes from util * chore: add additional test * chore: check-public-api change * Changes from lint:fix * chore: update test * chore: adjust all tests * chore: fix codeQL warning * Changes from lint:fix * chore: add changeset * chore: cleanup tests * feat: extend openapi request builder for basePath * chore: introduce setBasePath * feat: introduce _defaultBasePath to the generated files * chore: fix order of parameters with intro of basepath * chore: fix tests * chore: add setBasePath * chore: fix failing e2e test * Changes from lint:fix * chore: cleanup path * Changes from lint:fix * chore: adjust test * Changes from lint:fix * chore: switch to using undefined for default basePath value * chore: cleanup test * chore: update changeset * chore: adjust changeset * chore: fix unit test * chore:cleanup * chore: fix test * chore: cleanup changesets * fix: integration test * chore: fix path * chore:fix path * chore: remove dead code * chore: review comment * Update .changeset/chilled-flowers-hide.md Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/openapi/src/openapi-request-builder.ts Co-authored-by: Deeksha Sinha <[email protected]> * chore: address review comments * chore: revert update to removeSlashes utility * Changes from lint:fix * chore: address review comments * chore: tests fix * chore: adjust tests * chore: address review comments * Changes from lint:fix * fix: begin all paths using '/' * chore: address review comments * Update .changeset/chilled-flowers-hide.md Co-authored-by: Deeksha Sinha <[email protected]> * Update .changeset/chilled-flowers-freeze.md Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/util/src/remove-slashes.spec.ts Co-authored-by: Deeksha Sinha <[email protected]> * Update packages/util/src/remove-slashes.spec.ts Co-authored-by: Deeksha Sinha <[email protected]> * chore: address review comments * Changes from lint:fix * chore: add review changes * chore: address review comments * chore:address review comments * chore: address review comments * chore: release note fix --------- Co-authored-by: cloud-sdk-js <[email protected]> Co-authored-by: Junjie Tang <[email protected]> Co-authored-by: Deeksha Sinha <[email protected]>
Closes SAP/cloud-sdk-backlog#1259.
This approach enables customising the
basePath
both before and after client generation.It changes the generated client code to also add an additional
basePath
and pass it on to theOpenApiRequestBuilder
.A new
setBasePath()
method is also introduced in theOpenApiRequestBuilder
.Usage from a user would look like this:
v3-main
now, which is not for v4 development.main
branch (for v4), I've updated (V4-Upgrade-Guide.md)[./V4-Upgrade-Guide.md] in case my change has any implications for users updating to SDK v4