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

Bug - parameter separator logic #147

Open
mhamann opened this issue Mar 17, 2020 · 6 comments
Open

Bug - parameter separator logic #147

mhamann opened this issue Mar 17, 2020 · 6 comments

Comments

@mhamann
Copy link

mhamann commented Mar 17, 2020

I've got a situation where I'm taking an OpenAPI v3 doc, parsing it, and registering its paths in find-my-way via fastify.

However, I'm facing a problem where the OpenAPI doc has path parameters in the format {some-param}. I convert those to :some-param for find-my-way, but they're then interpreted as a parameter some + a path segment param. This is caused by this parsing logic: https://github.com/delvedor/find-my-way/blob/master/index.js#L131

I'll submit a PR, but I think that logic should ensure that the - character is followed by a : to indicate the second parameter. Otherwise, it should be assumed that it's just a continuation of the original parameter up to the next /.

@mcollina
Copy link
Collaborator

In #27, this feature was actually coded with - as a separator, so it's working as expected.

We can potentially change this in a semver-major (one is due soon), but it 's not clear how if we want to retain similar functionality (having a part of a segment being parametric).

@mhamann
Copy link
Author

mhamann commented Mar 18, 2020

Thanks for the background @mcollina. So, what's the expected behavior of /foo/:param-x vs. /foo/:param-x-:param-y?

@mhamann
Copy link
Author

mhamann commented Mar 18, 2020

I looked at https://github.com/delvedor/find-my-way/blob/master/test/issue-17.test.js and realized that my first example would make -x the suffix of the parameter. So now I better understand the comment you made.

What do you think about wrapping a param to indicate that it should be taken literally? e.g. /foo/:{param-x}?

@mcollina
Copy link
Collaborator

That would work.

@Ekott2006
Copy link

Hello, What's the next step??

@mcollina
Copy link
Collaborator

Somebody that needs this feature should work on it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants