Skip to content
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(rest): allow - to be used for path template variable names #2724

Closed
wants to merge 1 commit into from

Conversation

raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Apr 11, 2019

An OpenAPI spec for banking uses {account-id} as path variable names. Before this change, @loopback/rest reports it as invalid parameter name.

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@raymondfeng raymondfeng requested a review from bajtos as a code owner April 11, 2019 00:02
@raymondfeng raymondfeng changed the title Relax template variable names to allow - feat(rest): Relax template variable names to allow - Apr 11, 2019
@dhmlau
Copy link
Member

dhmlau commented Apr 11, 2019

@raymondfeng, I think some changes in this PR overlaps your other PR #2722. Are we going to abandon #2722, or they are meant to be separate changes?

Some specs use `{account-id}` as part of the path.
@raymondfeng raymondfeng force-pushed the relax-template-varname branch from 7fc2800 to 379a4a9 Compare April 11, 2019 02:30
@raymondfeng raymondfeng changed the title feat(rest): Relax template variable names to allow - feat(rest): allow - to be used for path template variable names Apr 11, 2019
@raymondfeng
Copy link
Contributor Author

I think some changes in this PR overlaps your other PR #2722. Are we going to abandon #2722, or they are meant to be separate changes?

It was a mistake from branching. Fixed.

@hacksparrow hacksparrow self-requested a review April 11, 2019 03:20
Copy link
Contributor

@hacksparrow hacksparrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add end-to-end tests for both /{foo-bar} and especially for /{foo}-{bar} to verify that we can route such paths correctly.


it('allows /{foo}-{bar}', () => {
const path = validateApiPath('/{foo}-{bar}');
expect(path).to.eql('/{foo}-{bar}');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a valid OpenAPI path? Will our two router implementations correctly handle such path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It turns out that - is not allowed by path-to-regexp as it does not match \w. I'll investigate more.

Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as @bajtos, but LGTM otherwise.

@bajtos bajtos added bug REST Issues related to @loopback/rest package and REST transport in general labels Apr 11, 2019
@raymondfeng
Copy link
Contributor Author

Close this PR with an alternate fix - b6e02fc.

@raymondfeng raymondfeng deleted the relax-template-varname branch April 11, 2019 15:19
@dhmlau dhmlau added this to the April 2019 milestone milestone Apr 15, 2019
@bajtos
Copy link
Member

bajtos commented Apr 16, 2019

Close this PR with an alternate fix - b6e02fc.

@raymondfeng How did this commit get into master? GitHub is not showing any linked pull request to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug REST Issues related to @loopback/rest package and REST transport in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants