-
Notifications
You must be signed in to change notification settings - Fork 117
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
Regression in 0.7.1 for actix web & tail matches #453
Comments
Looks like this was done by #430 |
Looking at https://swagger.io/specification/ i see that the parameter name should follow the following rules:
So this must follow Path Tempating rules, however I do not find any information about regex being allowed in the path templates? But, I wonder if it is not the path that is wrong, and should be stripped to match the name? Isn't the regex a actix-web specific thing? Is
|
Yeah the problem is that the filename on the path differers, so this yields invalid spec :( Since there is nothing on the spec about regex being valid or other I think we should keep it as it was before. We can add a option to keep or remove regex? But when the option is set to remove, remove it from the path as well. What do you think? |
I would have thought, stripping the regex out of the path and adding it as a pattern in the schema would be most correct. Keeping the regex on the name causes it to be visible to users in documentation as part of the name. This is not a huge problem, just a bit ugly. |
What do you mean by this?
Yeah fair point, which is why I think it should be configurable. In my case for example I need it because I have tooling that depends on it to generate the correct code. Is this case the user is not a regular user, but a dev tool :D |
In the example diff in OP , there are a schema section. A schema section can contain a pattern, which should be a regex. So, by moving the regex from the path and name, to the schema (in the pattern property) we should get the same semantics as the actix path syntax. |
You mean like:
Interestingly on the spec Format it says the following: So it seems a field name can be a regex? |
Well, under the Path section for Patterned Fields, it doesn't mention anything about regex at all.... it seems to just mean the "/example/{filename}": {
"get": {
"operationId": "get_example",
"parameters": [
{
"in": "path",
"name": "filename",
"required": true,
"schema": {
"type": "string",
"pattern": ".*"
},
"style": "simple"
}, is how I think the actix route cfg.service(web::resource("/example/{filename:.*}").route(web::get().to(get_example))) should be interpreted since in actix this means the path /example/{filename} where the filename matches ".** |
Yeah I'd be happy with that. @cetra3 looks good to you too? How would we do reversal to generate server side code from that yaml? Only if the pattern is explicitly ".*" do we pass that to the actix server? |
Well, since the pattern is regex shouldn't it just be reversed, so that the path would be |
Oh ok I thought actix didn't quite support regex, it's been a while since I looked at it. |
So to expand upon the issue a little more, we're using the openapi-generator-cli which does a pretty trivial "search & replace" against the path to build up the correct uri. With To clarify: in actix-web this syntax is not strictly regex, it's a special way of dictating a path route includes a tail match. That is: the param can include forward slashes. I.e,
Whereas
So I think this statement might not be entirely correct:
However: I agree that the example given example looks like it would solve the issue. |
I have now pushed a fix for this regression. The pattern in the template is removed when the paths is serialized. And the pattern is also set as a pattern in the parameter information. |
Hey looks like this one is still an issue in |
Oh then let's reopen it :( |
Looks like there has been a change to the way url path parameters are generated between
0.7.0
&0.7.1
. When using a tail match, which is normally defined by with a{param:.*}
in the url, this now has broken output.Here's an example config:
This matches anything that has the
/example/
prefix, including any extra slashes etc..Here's a diff of a service:
I would expect in this case the name still is
filename:.*
The text was updated successfully, but these errors were encountered: