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

Remove regexes for path parameters in the swagger file #23

Open
TenOs opened this issue May 24, 2017 · 1 comment
Open

Remove regexes for path parameters in the swagger file #23

TenOs opened this issue May 24, 2017 · 1 comment

Comments

@TenOs
Copy link

TenOs commented May 24, 2017

The swagger file generated with the library contains paths with regex, which make all the client tools to fail consuming the API.
For instance a url like this:

/test/{param1:regex1}/{param2:regex2}

is currently generating the following url in the swagger file:

/test/{param1:regex1}/{param2:regex2}

where it should instead generate:

/test/{param1}/{param2}

To solve this issue, I suggest using a regex like the following:

regex = re.compile(r'{(\w+):[^/]*}')
path = regex.sub(r'{\1}', path)

that could be added right before https://github.com/toumorokoshi/transmute-core/blob/master/transmute_core/swagger/__init__.py#L59

I tried to do it myself, but can't figure out how this uranium stuff is working for testing, and don't really have time to invest in it :(

@toumorokoshi
Copy link
Owner

toumorokoshi commented May 24, 2017

It sounds like you're referring to aiohttp-transmute in particular: that supports more a regex override and similar syntax to transmute's paths:

http://aiohttp.readthedocs.io/en/stable/web.html#variable-resources

Theoretically transmute's path syntax isn't supposed to mirror any particular framework: it's a coincidence that it matches aiohttp. Of course I understand that doesn't really help you, just giving some background.

For a solution, how about we modify the transmute path syntax to allow arbitrary annotations after colons? basically, anything after the colon is framework-specific metadata. For aiohttp, this would actually make the path syntax identical to normal routes, so

/test/{param1:regex1}/{param2:regex2}

would just work.

Regarding running the tests: Sorry to hear uranium was difficult for you. Did you run into an issue with running

./uranium test

?

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

No branches or pull requests

2 participants