I'm developing a new API using Slim Framework (v3).
I'm trying to integrate this API with Swagger UI, but when I click "Try it" button, Swagger generates the following link.
Example link:
http://localhost/api/public/contact?param1=1¶m2=2param3=3
It's correct if I don't use Slim, but a link for Slim API is like:
http://localhost/api/contact/1/2/3
What I want is that Swagger use a link to Slim API, how can I do to achieve that? I can't find a way to "translate" the link format.
I'm using Swagger-php for comments (annotations).
I hope you can help me. Thanks.
You have a couple different options.
First Swagger-ui won't show that link unless it's defined somewhere (i.e the basePath attribute) or left undefined. It sounds like there's something missing there.
Next, you can always override the basePath in your API like such:
window.swaggerUi.api.setBasePath('/api');
Which should take away the /api/public section.
It's a little difficult to debug without seeing your JSON or YAML swagger definition but those two techniques should get you over the hump.
Related
i tried to work with marketplace. They said that "Working with the API consists of sending a request and receiving a response. To do this, you can use the console to the right of the method descriptions, the Swagger interface"
Also, the link of "Swagger interface" => https://api-seller.ozon.ru/docs/#/
looks like this:
I`m a little bit confused, because i expected, that this is the library, or smth like this.
Link swagger.json
it`s a page with to json setting(as i think), picture is pretty view of plain text on that page:
so, i have no swagger library, but have this json.
Question:
Can i make from this json Swagger project?
When you click on swagger.json (as you shown in image with red arrow) it will redirect you to another page, this page have json configuration.
Copy this json and open https://editor.swagger.io/ this link, and paste your json.
After that, there is an option on menu 'Generate Client' it give you a various options to generate your client in Angular, C# and so on
My Laravel 5 Application is installed under the Directory Name:
MyAccount
I have following Url in the application:
http://localhost:1234/laravel/MyAccount/public/allskills
This is due to below route:
Route::get("/allskills", "Skills\SkillsController#index");
I am trying to change my Url to below:
http://localhost:1234/allskills
Question: Am I missing any setting in the above routing code ?
I'd recommend using laravel homestead. There are plenty of tutorials online (including screencasts on YouTube) that guide you through it. You can map a url like
"skills.app" to your MyAccount/public directory, so it can be accessed as
skills.app/allskills
If you want to find out more, check outt this short video series on YouTube, but of course if you don't want to go to these lengths you could use one of the answers already given.
I have created few applications in core php and now decided to move to CakePHP hoping to get better control over things. i was able to follow the cookbook blog example successfully but i understand angularjs well enough and love to work with it. i am following below article
https://github.com/hantsy/angularjs-cakephp-sample/wiki/2-rest-api
to make an api which can reply to my angularjs calls but when i call the page
http://localhost/posts.json at the end i get 404 : page not found error. not sure what is going on . I did not use the bake commands but i do have the Post model and controller well placed. Seems like there is something small thing i am missing may be in routing file . can you please help me overcoming this . Thanks for support !
pawan
Please add your cakephp folder name where your main app folder resides in url and after that it will look like this:
http://localhost/"your cakephp folder"/posts.json
Hope it helps.
Thanks
I'm working on updating my Slim API and wanted to add the ability to define the type of response for a route within the routes url. Similar to how Reddit or Rails does it where you can add a .html,.json, or .xml to a route and have that route return the proper formatted data. Below is a Reddit example of one route being able to return a json,xml, or html response by changing the ending to whatever response type.
http://www.reddit.com/r/ObjectiveC.json
Is this something I will have to do manually with middleware parsing every route or does Slim have this built in? Any help would be greatly appreciated.
Thanks
What you're looking for isn't natively available, but you might want to look at the ContentTypes Middleware in the Slim-Middleware repo. I think that'll get you close to where you need to go, although the type is detected via the content type header via \Slim\Http\Request::getMediaType.
I'm a Joomla developer and I'am trying to build a component(in J!1.5) that uses urlparam for creating custom menu links in the admin.
I want my component to work like the built-in polls component that allows users to select the id of an item in my component.
I tried the xml file for the component but that doesn't work. But I know it's possible, Community Builder is able to use it.
Since the Joomla documentation is lacking when it comes to this feature. Can someone be so kind to give me some insight into how to use implement this in my own components?
EDIT:
To clarify: I want to know how to create an input in com_menus with the name "urlparam". From my knowledge JParameter(the components xml file) can't do this.
EDIT2:
I'll keep the above for histical purposes but to farther clarify I would like a way to link to an internal page of a custom component from a menu without having to use a external url.
Thanks.
"urlparam" Do you mean the parameters passed in the URL or is that a specific function name?
The way to retrieve HTTP url encoded parameters in Joomla is to use the class Request.
eg:
JRequest::getVar('name', 'default value');
That retrieves the parameter $_REQUEST['name'] or the 'default value' if it does not exist or evaluates to FALSE.
There are a number of helpful methods of Request that passes the value through filters for you, like JRequest::getCmd(), JRequest::getInt() etc.
If you're talking about JParameter, which is the default class for handling configurations presented in the INI or XML files, you'll find the API docs helpful.
http://api.joomla.org/Joomla-Framework/Parameter/JParameter.html
However, in actual use in components, you should retrieve parameters from JFactory::getConfig() for global parameters, or for component parameters:
$config =& JComponentHelper::getParams( 'com_name' ); // where com_name is the component name
The API wiki should also help:
http://docs.joomla.org/Framework
Why exactly can't you just you just use an External Link menu type?
This is what I do. Just give it a relative link rather than an absolute one:
index.php?option=com_components&task=blah
Presumably this isn't any different from constructing a URL to execute a command inside your component.
JRequest::getVar('name', 'default value');
Also check http://docs.joomla.org/Framework
(wanted to upvote answer 1 but wouldn't let me until I get more points.. so I'm giving the same in short answer form)