This question already has answers here:
Swagger: wildcard path parameters
(2 answers)
swagger: file path in path parameter
(1 answer)
Closed 2 years ago.
Some of my APIs use a file path as the path parameter (Ex. .../hello/test.txt) which will include a forward slash. However in Swagger, it always escapes the forward slash such that my intended URL of
https://editor.swagger.io/DStoreRESTExample/api/v1/hello/test.txt
becomes
https://editor.swagger.io/DStoreRESTExample/api/v1%2Fhello%2Ftest.txt which throws errors because it's not a valid URL.
Is there any way to work around this? From what I understand is that they don't plan on putting a fix to this even in future releases of Swagger.
Related
This question already has answers here:
URLs: Dash vs. Underscore [closed]
(18 answers)
Closed 8 months ago.
I'm getting a little confused about choosing the more right URL i would appreciate if you could recommend which one is better
domain.com/admin/manage_vehicles
or
domain.com/admin/manage-vehicles
or
domain.com/admin/manage/vehicles
The 3rd way is the most user friendly way to make a URL.
It will be more useful when you have multiple routes of that same category.
domain.com/admin/manage/vehicles
domain.com/admin/manage/drivers
domain.com/admin/manage/passengers
But as an alternative, you can use the the 2nd way too.
domain.com/admin/manage-vehicles
domain.com/admin/manage-drivers
domain.com/admin/manage-passengers
Hyphens are recommended by Google over underscores (source).
Hyphens are more familiar to the end user.
And last of all, underscores and keyword joins are not recommended in URLs.
domain.com/admin/manage_vehicles
domain.com/admin/manageVehicles
This question already has answers here:
Dots in URL causes 404 with ASP.NET mvc and IIS
(18 answers)
Closed 7 years ago.
One of my Web API takes IP address as a URL param (string type) and does something with it. The problem is that I'm not able to pass an IP address as part of the URL.
It's a HTTP GET. A request of http://localhost/app/dosomethingwiththisip/10.20.128.0 fails while http://localhost/app/dosomethingwiththisip/10 succeeds (even though it fails in terms of what needs to be done with it).
Web API method is defined as, with attribute routing enabled,
[Route("dosomethingwiththisip/{ipAddress}")]
[HttpGet]
public bool dosomethingwiththisip(string ipAddress)
{
}
Am I doing something wrong?
I finally went with a simple solution of appending a slash character at the end of the URL after the IP address. Thanks to #Pharylon for the tip to a similar question, Dots in URL causes 404 with ASP.NET mvc and IIS
If you are specifying a url parameter and not a file or directory name, then you should prefix your list of parameters with ? so the web server knows. It can't tell what you intended.
Try: http://localhost/app/dosomethingwiththisip/?10.20.128.0
This question already has answers here:
IIS7 URL Rewriting Module Replace
(5 answers)
Closed 3 years ago.
I want
Input :www.example.com/videos/video1%2Cvideo2%2Cvideo3%2Cvideo4%2C Output:www.example.com/videos/video1,video2,video3,vide4
So i need regular expression. I tried this:^videos/[%2C](in iss url rewriting pattern). But not it is not work. It said the input data to test does not match the patter.
In your query, you mentioned it as "video", whereas in your regular expression, it is mentioned as "videos". This typo might be reason for the pattern mismatch error. Please cross check.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What is the “?” symbol in URL used for in php?
In the websites based on PHP usually has "?" in URL,
i.e. http://host/wordpress/?p=276
What is the meaning of "?" in the URL?
The "?" is not related to PHP only. This is the symbol which starts the begining of query. Format is:
www.serverhost.com/script.php?parameter1=A¶meter2=B
When browser requests server with this query the server parses it and passes parameters to the script, for example in PHP you will receive those parameters in $_GET array, i.e:
$_GET['parameter1'] will contain 'A', and $_GET['parameter2'] will contain 'B'.
It separates the URL path from the query string.
http://en.wikipedia.org/wiki/Uniform_Resource_Locator
You might want to have a look at the query string
It's using GET to store a variable called p with a value of 277.
In PHP you can read that variable by running
<?
echo $_GET['p'];
?>
On this page that would say 277.
In this case, it's used to mean this is post number 277. The code will check this is a number, then look up the post with id 277 in the database.
seperation of http address and parameters passed to that address
? indicates the beginning of the query part of the URI. Please refer RFC3986
When the forms (like login or register or any other kind of forms) are sending values )onclick of submit button) if that form is sent by 'GET' method then the values sent are visible in URL with appending '?' at the end and values next to that
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Ruby code to extract host from URL string
I found this module called URI which can parse the url. (I'm pretty new to ruby. Is 'module' synonymous with 'library' in this case?) You can then extract the host name.
uri = URI.parse("http://www.ruby-lang.org/")
...
p uri.host
# => "www.ruby-lang.org"
From this, I suppose you could remove 'www.' and keep other subdomains using regular expressions.
Does anyone have a more straight-forward alternative or does this approach seem right?
So while posting my own answer, I'm not saying that gems like domainatrix or public_suffix_server aren't good elegant solutions (although the latter bugged on me immediately which caused me to go this route).
People suggesting using split() made me realize that I could just sub out 'www.' if it existed and otherwise leave domains as they are without installing gems and using 1 simple line of code:
url = request.original_url
domain = URI.parse(url).host.sub(/\Awww\./, '')
This works with subdomains and multi-part suffixes (eg. co.uk). Anybody see anything wrong with this?
EDIT: Thanks sorens for pointing out the weak regex I was originally using. This expression is certainly better.
You can use domainatrix gem to get what you want: url.domain + url.public_suffix, but you can just do some string manipulation like uri[4..-1].