Dynamic Host can be passed except giving in .json file? - swagger

I am using Swagger-ui version 2.1.4, i have hosted it locally and provided it my own Json file and API it opens the document fine and lists all the method in the json file, host is given in .json file. i want to change it, that it is given by the user every time when it calls the index page.
"host" : "localhost:1234"

You can programmatically set the host:
window.swaggerUi.api.setHost('localhost:1234')
If you leave the host field off, it'll use the same host that the UI is served from.

Related

WOPI Host implementation, trying to render doc in iframe

I'm trying to get Wopi host implementation in Ruby on Rails application.
My domain is whitelisted under CSPP. Trying to get the file contents in iframe, but I just see "Word Online" and a loading gif, I return binary file contents of docx as response to ..wopi/files/:id/contents. I don't get any calls hitting my host server.
Sample wopi_src_url: https://word-view.officeapps-df.live.com/wv/wordviewerframe.aspx?ui=1033&rs=1033&dchat=false&IsLicensedUser=0&WOPISrc=https://sgdevwopi.test-wopi.sycamoreinformatics.com/wopi/files/31/contents?access_token=eyJhbGciOiJIUzI1NiJ9.eyJ1c2&access_token_ttl=160000000
Able to get the Wopi validation page in Iframe using .wopitest file. How should I proceed further? Or what am I missing? Please help.
Note: I'm using ngrok to make my local app server visible publicly with whitelisted domain.
I see to problems with your URL. You must ensure that
the URL is of the form http://server/<...>/wopi/files/(file_id) (so drop the /contents part - WOPI client will call the /contents endpoint automatically when necessary)
the WOPISrc parameter value is encoded to a URL-safe string
More info here and here.

Heroku: restrict access to files in public/ by IP?

I've got an app on Heroku that contains uglified JS code. I'd like to include my original sources (.js) in my public folder so that I can refer to them from a source map for debugging. I don't want the source files to be viewable by just anyone, however: I'd like to restrict access to a certain set of IPs.
In other words, in my Rails app on Heroku I'd like to have a file here:
myapp.herokuapp.com/unminified_sources/my_file.js
And I'd like to restrict access to this file to a certain IP (mine).
Is this possible on Heroku? How? Can I use an .htaccess file?
You can put the file behind a unminified_sources_controller my_file action that responds to js requests and restrict it that way. You can restrict in the route or add a before_filter to test for IPs.
You can stream the file. http://guides.rubyonrails.org/action_controller_overview.html#sending-files

Is it possible to save the swagger url in a browser bookmark

I am using swagger-ui and have different servers/interfaces/. So for each of them I store a bookmark - but the URL used in the swagger-ui is never ever saved within the bookmark. I always have to type in the address again.
Is it possible to save the URL used in the swagger-ui in a browser bookmark (for example as a special parameter)?
If your swagger-ui is running here:
file:///Users/me/work/swagger-ui/dist/index.html
And your server is running here:
http://localhost:8080/api-docs
Then you can bookmark the swagger-ui for your server like so (a simple GET with a param named "url"):
file:///Users/me/work/swagger-ui/dist/index.html?url=http://localhost:8080/api-docs

Maximo 5.2 Can upload attachment to the server but can't view them on client side

Ok I know Maximo 5.2 is horribly outdated but currently I just want to get the attachment working. So here is the situation:
I have an old server (running 2000) with a folder being shared on the network with the name of F$. I have tried that the attachment uploading functionality works fine: users can attach any file to a work order and that file will be copied into a specified folder in the F: drive of the server. But when I try to access to that file from the client side -- that is, click on the link within the work order (from attachment tab in Maximo webapp) in order to view the attachment -- I get a 404 response. So in a way it's like I am able to write to the server but somehow I can't read or download it from the client side.
UPDATE:
I found out that after you've uploaded a file to the server, it can be accessed from the link http://servername:port/doclinks/drawings/filename from any other client side desktop in the browser. However within the Maximo web app, the webpage javascript automatically parse the link as http://servername/f$/MAXIMO/doclinks/drawings/filename -- It returns redundant part and withno port number. Is this returned link configurable through settings or do I have to dig into the JSP?
You need to set up virtual directory mapping on weblogic
http://docs.oracle.com/cd/E11035_01/wls100/webapp/weblogic_xml.html
The files are on the server. You just to correctly map the doclinks root on the file system to make it accessible to the web. You are getting a 404 error because the mapping is wrong.
In c:\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF look for weblogic.xml
Add an entry:
<virtual-directory-mapping>
<local-path>/apps/maximo/</local-path>
<url-pattern>/doclinks/*</url-pattern>
</virtual-directory-mapping>
The entry above sits between <weblogic-web-app> and </weblogic-web-app>
The above example would mean your doclinks directory on the server is /apps/maximo/doclinks/
You would need to edit weblogic.xml, redeploy your maximo.ear along with your doclinks.
Because you are getting http://servername/f$/MAXIMO/doclinks/drawings/filename, particularly the f$/MAXIMO part, it tells me your F<PATH>\\MAXIMO\\doclinks = http://servername:port/doclinks mapping in your doclinks.properties is not correct. If you are on the Maximo host, via remote desktop or whatever, and you open Windows Explorer, what do you need to put in the address bar to access the attached documents folder? You said it's on F$, but F<PATH> in your properties file will translate into F:, not F$. So, you need to change your doclinks.properties
from: F<PATH>\\MAXIMO\\doclinks = http://servername:port/doclinks
to: \\\\servername\\F$\\MAXIMO\\doclinks = http://servername:port/doclinks

Access Asset Path from Rails Controller

I'm sharing a configuration yml file client side, that I need to also load on the server side, I've placed it inside app/assets/javascripts/configuration.yml
I can use #{asset_path 'configuration.yml'} inside a view to get the path, but I can't inside a controller. I could access directly using "#{Rails.root}/app/assets/javascripts/configuration.yml" but when deploying the filename gets the digest string appended.
How can I get the same path from a controller?
ActionController::Base.helpers.asset_path("configuration.yml")
Might also be good to put configuration.yml in a different folder to separate javascript from non-javascript files.

Resources